staging: greybus: audio_codec: fix sscanf return value check

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>
Link: https://patch.msgid.link/20260614154329.5176-2-abdelnasserhussein11@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Abdelnasser Hussein
2026-06-14 18:43:28 +03:00
committed by Greg Kroah-Hartman
parent 1f4597ab96
commit d1314cadc2

View File

@@ -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;
}