This patch series addresses two separate issues in gbaudio_module_update() that were previously combined in v2:
1. Fixes an improper check of the sscanf() return value (smatch warning). 2. Removes a redundant else-if check that could lead to an uninitialized variable warning for 'ret' (reported by kernel test robot).
Changes in v3: - Split the changes into a 2-patch series based on feedback from Greg Kroah-Hartman. - Assigned correct Reported-by and Closes tags to both patches.
abdelnasser hussein (2): staging: greybus: audio_codec: fix sscanf return value check staging: greybus: audio_codec: remove redundant else-if check
drivers/staging/greybus/audio_codec.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
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; }
On Sun, Jun 14, 2026 at 06:43:28PM +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
There shouldn't be a blank line in the middle of the tags block.
The closes tag isn't right... https://lore.kernel.org/all/202103080429.X31wogmF-lkp@intel.com/ Sorry, this stuff is a bit confusing to everyone who is not involved with the zero day bot. What happens is that for some warnings, they first send the warning to me and I look it over and decide whether or not it's valid. In this case, I decided it wasn't valid. Sure, I can understand why the static checker thinks we're propagating the return from sscanf() but actually the second else if is always true.
(I haven't actually checked that btw, I'm just assuming that the second else if is always true. Static analysis is always a best effort type of thing).
regards, dan carpenter
In gbaudio_module_update(), the widget id is validated earlier in the function to ensure it is either snd_soc_dapm_aif_in or snd_soc_dapm_aif_out.
Remove the redundant else-if check for snd_soc_dapm_aif_out. The remaining branch can only handle snd_soc_dapm_aif_out, which avoids a compiler warning about a potentially uninitialized variable.
Reported-by: kernel test robot lkp@intel.com Closes: https://lore.kernel.org/oe-kbuild-all/202606140347.gGVWDnbi-lkp@intel.com/
Signed-off-by: Abdelnasser Hussein abdelnasserhussein11@gmail.com --- Changes in v3: - Split from the previous v2 patch to address the uninitialized variable warning separately.
drivers/staging/greybus/audio_codec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/greybus/audio_codec.c b/drivers/staging/greybus/audio_codec.c index 295222ec0f1a..6daa4e706792 100644 --- a/drivers/staging/greybus/audio_codec.c +++ b/drivers/staging/greybus/audio_codec.c @@ -322,7 +322,7 @@ int gbaudio_module_update(struct gbaudio_codec_info *codec, ret = gbaudio_module_enable_tx(codec, module, dai_id); else ret = gbaudio_module_disable_tx(module, dai_id); - } else if (w->id == snd_soc_dapm_aif_out) { + } else { if (enable) ret = gbaudio_module_enable_rx(codec, module, dai_id); else