From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oa1-f53.google.com (mail-oa1-f53.google.com [209.85.160.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AAE663DCD8F for ; Tue, 30 Jun 2026 18:59:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782845986; cv=none; b=riRK2ZN+C2NOaapWMYcvTcg6yyU8/gwwWTBFWFeipuJuK5PvIdtMjWPFPouIX5KpIO3R+RKG6Xk9v15ikF8qXBv28a+Tl7jU9xIOKn+Xdu/wZAW/0Tb8vK6DJ7QnrumCGX/QxjyPQDdjMfUCACPgBRIcz8VoT0gPZ+PiY0kINPQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782845986; c=relaxed/simple; bh=TM3lyK9Sb9Y4b0/e2BYwMPDJS+VDqJQGll2tCdyfabE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=muUw2WdlKWIHutZz7Xmv7z29/XEQB3gy1jSuD3Xg0ZOwj04uwNWxcynqPgOrxl0mKjCeqqEd3t2DSXoXa3YrovkXhn1l3T5xs5FJ6FU0pmQZ0qPIcRrV0JokM3eozn+k5cO7qOo0mADbUWn6GFKAlg5gnXgjfXcH0H2WsIcCM48= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=MhkhZ5yJ; arc=none smtp.client-ip=209.85.160.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MhkhZ5yJ" Received: by mail-oa1-f53.google.com with SMTP id 586e51a60fabf-44755d837e8so3249367fac.3 for ; Tue, 30 Jun 2026 11:59:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782845984; x=1783450784; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=vVDK+7rfTbcz4GcngokUtqAZsOvebPGcWgNYsKQ5g3w=; b=MhkhZ5yJc9i2kmiTmdXQd9vkC7dREQipa6oegHg1ouzqjyt85xPT69L5W7mBi56z7L 7UWtaVz/upKc1CPzdgwcBjaNPGSX85I0Kk2Nl6A3yCcgfM7QyfdHbwoQqS4D7R9zX8T0 gKiuES//qr+aLnsb4ElGFCC27N9V2cG5Fqxb70koGcDsoB7ReZe/AQuqZyKyfMah/Bd+ hPES5IUz4ryiZNHMrV9mwaKrT0LyKAA2ciNr9TTajY7IRh1k6H9huc6fi3mpwc5QqyrC 6iJUxgweNc6qdxgqaX3bJEdNywiYocaLIULxuuKELe0BSMyQhDglLT6/E+tjujvpBJdB Brtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782845984; x=1783450784; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vVDK+7rfTbcz4GcngokUtqAZsOvebPGcWgNYsKQ5g3w=; b=Pb65WU9Y2k9fn4LmANaylXjKt2LlgnhfpuojnqMdsFyqqqzyFgmV8eXPvXI/f5G92i w5aJiRDH3jDq7Eyye775RZvYwX+7ZanE3JEQO858gaLoxO+On4nFGGV8EF1S5F4Grpxl vc9XYkb1SYmALIoRdt8YHiOkBGAdhVFszPmfQlxqDqgf7I09xBGCEEMeZUfxnr5CAO8R 4guuKljlgd6RoI0rM2F7MmsEXZqXX9q6+WURAnQOUD87ejR2SGDzSUJzgTPKW1gbG36/ qlrylTDdAu7+IW+bD8LK6urFAY5iUqX+VUH5e8j70HkTLMPROFM0xQtXOJNUUPL6MF10 6zKA== X-Forwarded-Encrypted: i=1; AFNElJ+Uj4bpD4K9BtuDzXdKfhKho309f/3clDLElCwzQBuk+clBznHFEOnFHSCS0npUGeqyANdC014JWEDjVwA=@vger.kernel.org X-Gm-Message-State: AOJu0Yy9c2VLIPjQg00xlWJzowl0nQ62U8jzlEEbzV6a23Y8z3FW3os3 Mwm7WAXHrMCztLX7CUhQXiShTH3V4+if3lFiCUnSrjOcbouJ5l1W/DYu X-Gm-Gg: AfdE7clpDUQ3+GkcK8v7hlYGeg4UWTZKAUffYQPoXzy3BWSGAVdmcU2NKo7V1fpbTyk hLsXWtVa5bDaEz/yvEPfm2DYXOxVni0lihJKfCbjiYle9gT51ZobkqDAMHbXhxpbeMJr0AYJGRP k9N0cId8wmr163Szh+PA37RCp8mBv7QCjy56MDAOmxqqGacf8VbbpGQ6AW2/Ze96+p9u5lg1NJl Fti/xjn33fSCQ0gD16Frkw/FpFpM0D+HpwqY4PtuGpvINpH81nCMr3HlKJ0/EdEM2PQ/CBCr7MW kHMl+OU62fofpJevjUEe1ZR93ttEQNM5Wl8TU6AdLPvC3eFeVdM4FgmqUNQGZcJWhMTbaEETWVW gImxOR7NfeL6toUXt0L0rbH1dZwxDKT5rlypYuk2mCfS+R1ga4uQOplE8oPzF7fjsHvoYDlNDQI l1aEtm X-Received: by 2002:a05:6871:8b87:b0:44a:f310:407c with SMTP id 586e51a60fabf-44af3106221mr787596fac.15.1782845983676; Tue, 30 Jun 2026 11:59:43 -0700 (PDT) Received: from localhost ([74.80.182.83]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-448dbee3b97sm3008034fac.10.2026.06.30.11.59.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2026 11:59:42 -0700 (PDT) Date: Tue, 30 Jun 2026 21:59:36 +0300 From: Dan Carpenter To: adi25charis@gmail.com Cc: vaibhav.sr@gmail.com, mgreer@animalcreek.com, johan@kernel.org, elder@kernel.org, gregkh@linuxfoundation.org, greybus-dev@lists.linaro.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] staging: greybus: audio: split gb_audio_gb_get_topology() Message-ID: References: <20260630164602.37663-1-adi25charis@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260630164602.37663-1-adi25charis@gmail.com> On Tue, Jun 30, 2026 at 10:16:02PM +0530, adi25charis@gmail.com wrote: > From: Aditya Chari S > > Split gb_audio_gb_get_topology() into two functions: > gb_audio_gb_get_topology_size() to fetch the topology size, and > gb_audio_gb_get_topology() to fetch the topology data into a > caller-provided buffer. This moves buffer allocation out of the > audio_gb protocol helper and into gb_audio_probe(), where it > belongs, addressing a long-standing FIXME. > > Signed-off-by: Aditya Chari S > --- > v2: > - Store size as size_t instead of u16, per Dan Carpenter. > - Move the size validation (size < sizeof(*topology)) out of > gb_audio_gb_get_topology() and into gb_audio_probe(), before > the kzalloc(), per Dan Carpenter. > - Fix dev_err() format strings so %d is no longer printed first; > put it at the end of the message instead, per Dan Carpenter. > > Compile-tested with `make M=drivers/staging/greybus modules`. > All modified files (audio_codec.h, audio_gb.c, audio_module.c) > compile without errors or warnings. checkpatch.pl --no-tree passes > clean on all three files. > --- This v2 patch is built on top of the v1 patch which we're not going to apply. It needs to be folded into the v1 patch instead. > drivers/staging/greybus/audio_codec.h | 4 ++-- > drivers/staging/greybus/audio_gb.c | 7 ++----- > drivers/staging/greybus/audio_module.c | 12 +++++++++--- > 3 files changed, 13 insertions(+), 10 deletions(-) > > diff --git a/drivers/staging/greybus/audio_codec.h b/drivers/staging/greybus/audio_codec.h > index be5a2a86b..b45cd257d 100644 > --- a/drivers/staging/greybus/audio_codec.h > +++ b/drivers/staging/greybus/audio_codec.h > @@ -179,9 +179,9 @@ void gbaudio_unregister_module(struct gbaudio_module_info *module); > > /* protocol related */ > int gb_audio_gb_get_topology_size(struct gb_connection *connection, > - u16 *size); > + size_t *size); > int gb_audio_gb_get_topology(struct gb_connection *connection, > - struct gb_audio_topology *topology, u16 size); > + struct gb_audio_topology *topology, size_t size); > int gb_audio_gb_get_control(struct gb_connection *connection, > u8 control_id, u8 index, > struct gb_audio_ctl_elem_value *value); > diff --git a/drivers/staging/greybus/audio_gb.c b/drivers/staging/greybus/audio_gb.c > index e6356643d..2e6f155d8 100644 > --- a/drivers/staging/greybus/audio_gb.c > +++ b/drivers/staging/greybus/audio_gb.c > @@ -9,7 +9,7 @@ > #include "audio_codec.h" > > int gb_audio_gb_get_topology_size(struct gb_connection *connection, > - u16 *size) > + size_t *size) > { > struct gb_audio_get_topology_size_response size_resp; > int ret; > @@ -26,11 +26,8 @@ int gb_audio_gb_get_topology_size(struct gb_connection *connection, > EXPORT_SYMBOL_GPL(gb_audio_gb_get_topology_size); > > int gb_audio_gb_get_topology(struct gb_connection *connection, > - struct gb_audio_topology *topology, u16 size) > + struct gb_audio_topology *topology, size_t size) > { > - if (size < sizeof(*topology)) > - return -ENODATA; > - > return gb_operation_sync(connection, GB_AUDIO_TYPE_GET_TOPOLOGY, NULL, 0, > topology, size); > } > diff --git a/drivers/staging/greybus/audio_module.c b/drivers/staging/greybus/audio_module.c > index 1163cf093..806533f03 100644 > --- a/drivers/staging/greybus/audio_module.c > +++ b/drivers/staging/greybus/audio_module.c > @@ -239,7 +239,7 @@ static int gb_audio_probe(struct gb_bundle *bundle, > struct gb_audio_manager_module_descriptor desc; > struct gbaudio_data_connection *dai, *_dai; > int ret, i; > - u16 size; > + size_t size; > struct gb_audio_topology *topology; > > /* There should be at least one Management and one Data cport */ > @@ -307,7 +307,13 @@ static int gb_audio_probe(struct gb_bundle *bundle, > > ret = gb_audio_gb_get_topology_size(gbmodule->mgmt_connection, &size); > if (ret) { > - dev_err(dev, "%d:Error while fetching topology size\n", ret); > + dev_err(dev, "Error while fetching topology size: %d\n", ret); Just leave this one as-is. It's from the original code. Although you added the word "size" so I guess that kind of makes changing it acceptable as well. The rule is you're allowed to make minor white space changes to line you're touching. So I guess either way is fine. > + goto disable_connection; > + } > + > + if (size < sizeof(*topology)) { > + dev_err(dev, "Invalid topology size: %zu\n", size); > + ret = -ENODATA; I would probably have said -EINVAL is more appropriate. > goto disable_connection; > } > > @@ -319,7 +325,7 @@ static int gb_audio_probe(struct gb_bundle *bundle, > > ret = gb_audio_gb_get_topology(gbmodule->mgmt_connection, topology, size); > if (ret) { > - dev_err(dev, "%d:Error while fetching topology\n", ret); > + dev_err(dev, "Error while fetching topology: %d\n", ret); This change is entirely unrelated so it's not allowed. regards, dan carpenter > goto free_topology; > } > > -- > 2.53.0