From: Dan Carpenter <dan.carpenter@linaro.org>
To: Khaled Saleh <khaled.saleh.req@gmail.com>
Cc: gregkh@linuxfoundation.org, linux-staging@lists.linux.dev,
greybus-dev@lists.linaro.org
Subject: Re: [PATCH] staging: greybus: split gb_audio_gb_get_topology() into helper functions
Date: Mon, 5 Jan 2026 12:29:09 +0300 [thread overview]
Message-ID: <aVuEZQ11i0gS_t7q@stanley.mountain> (raw)
In-Reply-To: <20251221194200.3734-1-khaled.saleh.req@gmail.com>
On Sun, Dec 21, 2025 at 09:42:00PM +0200, Khaled Saleh wrote:
> From: khaled <khaled.saleh.req@gmail.com>
Full name, please.
>
> The gb_audio_gb_get_topology() function performs multiple distinct
> operations: retrieving the topology size, allocating the topology buffer,
> and fetching the topology data. A TODO comment in the file notes that
> this logic should be split into separate calls.
>
> Introduce helper functions for each step and update
> gb_audio_gb_get_topology() to use them.
>
> This improves readability and maintainability without changing behavior.
>
> Signed-off-by: Khaled Saleh <khaled.saleh.req@gmail.com>
> ---
> drivers/staging/greybus/audio_gb.c | 47 +++++++++++++++++++++++-------
> 1 file changed, 36 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/staging/greybus/audio_gb.c b/drivers/staging/greybus/audio_gb.c
> index 9d8994fdb41a..0d5109ec14f6 100644
> --- a/drivers/staging/greybus/audio_gb.c
> +++ b/drivers/staging/greybus/audio_gb.c
> @@ -9,36 +9,61 @@
> #include "audio_codec.h"
>
> /* TODO: Split into separate calls */
> +static int gb_audio_topology_get_size(struct gb_connection *connection, u16 *size)
Use size_t for sizes.
> +{
> + struct gb_audio_get_topology_size_response resp;
> + int ret;
> +
> + ret = gb_operation_sync(connection,
> + GB_AUDIO_TYPE_GET_TOPOLOGY_SIZE,
> + NULL, 0,
> + &resp, sizeof(resp));
> + if (ret)
> + return ret;
> +
> + *size = le16_to_cpu(resp.size);
> +
> + return 0;
> +}
> +
> +static struct gb_audio_topology *gb_audio_topology_alloc(u16 size)
Same.
> +{
> + if (size < sizeof(struct gb_audio_topology))
> + return NULL;
> +
> + return kzalloc(size, GFP_KERNEL);
> +}
> +
> +static int gb_audio_topology_fetch(struct gb_connection *connection,
> + struct gb_audio_topology *topo, u16 size)
Same.
It's fine for now since there is just one caller, but using anything
other that size_t for sizes is just asking for integer overflow bugs.
regards,
dan carpenter
next prev parent reply other threads:[~2026-01-05 9:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-21 19:42 [PATCH] staging: greybus: split gb_audio_gb_get_topology() into helper functions Khaled Saleh
2025-12-22 6:23 ` Greg KH
2026-01-05 9:29 ` Dan Carpenter [this message]
-- strict thread matches above, loose matches on Subject: below --
2025-12-22 16:15 Khaled Saleh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aVuEZQ11i0gS_t7q@stanley.mountain \
--to=dan.carpenter@linaro.org \
--cc=gregkh@linuxfoundation.org \
--cc=greybus-dev@lists.linaro.org \
--cc=khaled.saleh.req@gmail.com \
--cc=linux-staging@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox