From: Greg KH <gregkh@linuxfoundation.org>
To: Abdelnasser Hussein <abdelnasserhussein11@gmail.com>
Cc: jic23@kernel.org, nuno.sa@analog.com,
Michael.Hennerich@analog.com, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org,
Dan Carpenter <dan.carpenter@oracle.com>
Subject: Re: [PATCH v3 1/2] staging: greybus: audio_codec: fix sscanf return value check
Date: Mon, 3 Aug 2026 17:29:08 +0200 [thread overview]
Message-ID: <2026080313-dubbed-palace-d33e@gregkh> (raw)
In-Reply-To: <20260803134346.6733-2-abdelnasserhussein11@gmail.com>
On Mon, Aug 03, 2026 at 04:43:43PM +0300, Abdelnasser Hussein wrote:
> Smatch static checker warns:
> drivers/staging/greybus/audio_codec.c:335 gbaudio_module_update()
> warn: sscanf doesn't return error codes
>
> The sscanf() function returns the number of successfully matched input
> items, not a negative error code. Compare the return value directly
> with the expected number of conversions (3) instead of storing it in
> 'ret' and returning it as an error code, which leads to returning
> a positive value on failure.
>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Closes: https://lore.kernel.org/all/YoOLnDkHgVltyXK7@kili/
>
> Signed-off-by: Abdelnasser Hussein <abdelnasserhussein11@gmail.com>
> ---
> Changes in v3:
> - Split from the previous v2 patch into a separate patch.
> - Updated tags to properly credit Dan Carpenter for the smatch warning.
>
> drivers/staging/greybus/audio_codec.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/staging/greybus/audio_codec.c b/drivers/staging/greybus/audio_codec.c
> index 720aa752e17e..295222ec0f1a 100644
> --- a/drivers/staging/greybus/audio_codec.c
> +++ b/drivers/staging/greybus/audio_codec.c
> @@ -311,8 +311,7 @@ int gbaudio_module_update(struct gbaudio_codec_info *codec,
> }
>
> /* parse dai_id from AIF widget's stream_name */
> - ret = sscanf(w->sname, "%s %d %s", intf_name, &dai_id, dir);
> - if (ret < 3) {
> + if (sscanf(w->sname, "%s %d %s", intf_name, &dai_id, dir) != 3) {
> dev_err(codec->dev, "Error while parsing dai_id for %s\n", w->name);
> return -EINVAL;
> }
> --
> 2.54.0
>
You didn't cc: the staging list? And the blank line above your
signed-off-by isn't going to work well. Please, when you split patches
up, be mindful of what tree they are going to.
thanks,
greg k-h
next prev parent reply other threads:[~2026-08-03 15:29 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-03 13:43 [PATCH v3 0/2] staging: iio: ad7816: Fix DMA from stack and race conditions Abdelnasser Hussein
2026-08-03 13:43 ` [PATCH v3 1/2] staging: greybus: audio_codec: fix sscanf return value check Abdelnasser Hussein
2026-08-03 15:29 ` Greg KH [this message]
2026-08-03 13:43 ` [PATCH v3 1/2] staging: iio: ad7816: serialize ad7816_spi_read() with a mutex Abdelnasser Hussein
2026-08-04 23:59 ` Jonathan Cameron
2026-08-05 12:25 ` nasser
2026-08-03 13:43 ` [PATCH v3 2/2] staging: greybus: audio_codec: remove redundant else-if check Abdelnasser Hussein
2026-08-03 13:43 ` [PATCH v3 2/2] staging: iio: ad7816: avoid DMA from stack in spi_read Abdelnasser Hussein
2026-08-05 0:05 ` Jonathan Cameron
2026-08-05 12:21 ` nasser
-- strict thread matches above, loose matches on Subject: below --
2026-06-14 15:43 [PATCH v3 0/2] staging: greybus: audio: cleanups for gbaudio_module_update Abdelnasser Hussein
2026-06-14 15:43 ` [PATCH v3 1/2] staging: greybus: audio_codec: fix sscanf return value check Abdelnasser Hussein
2026-06-15 7:35 ` Dan Carpenter
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=2026080313-dubbed-palace-d33e@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=Michael.Hennerich@analog.com \
--cc=abdelnasserhussein11@gmail.com \
--cc=dan.carpenter@oracle.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.