2023-05-04 07:00:31

by Ruliang Lin

[permalink] [raw]
Subject: [PATCH] sound: caiaq: input: Add error handling for unsupported input methods in `snd_usb_caiaq_input_init`

Smatch complains that:
snd_usb_caiaq_input_init() warn: missing error code 'ret'

This patch adds a new case to handle the situation where the
device does not support any input methods in the
`snd_usb_caiaq_input_init` function. It returns an `-EINVAL` error code
to indicate that no input methods are supported on the device.

Fixes: 523f1dce3743 ("[ALSA] Add Native Instrument usb audio device support")
Signed-off-by: Ruliang Lin <[email protected]>
Reviewed-by: Dongliang Mu <[email protected]>
---
The issue is found by static analyzer. The patched code has passed
Smatch checker, but remains untested on real device.
---
sound/usb/caiaq/input.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/sound/usb/caiaq/input.c b/sound/usb/caiaq/input.c
index 1e2cf2f08eec..84f26dce7f5d 100644
--- a/sound/usb/caiaq/input.c
+++ b/sound/usb/caiaq/input.c
@@ -804,6 +804,7 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *cdev)

default:
/* no input methods supported on this device */
+ ret = -EINVAL;
goto exit_free_idev;
}

--
2.25.1


2023-05-04 07:14:29

by Daniel Mack

[permalink] [raw]
Subject: Re: [PATCH] sound: caiaq: input: Add error handling for unsupported input methods in `snd_usb_caiaq_input_init`

On 5/4/23 08:50, Ruliang Lin wrote:
> Smatch complains that:
> snd_usb_caiaq_input_init() warn: missing error code 'ret'
>
> This patch adds a new case to handle the situation where the
> device does not support any input methods in the
> `snd_usb_caiaq_input_init` function. It returns an `-EINVAL` error code
> to indicate that no input methods are supported on the device.
>
> Fixes: 523f1dce3743 ("[ALSA] Add Native Instrument usb audio device support")
> Signed-off-by: Ruliang Lin <[email protected]>
> Reviewed-by: Dongliang Mu <[email protected]>

Acked-by: Daniel Mack <[email protected]>



> ---
> The issue is found by static analyzer. The patched code has passed
> Smatch checker, but remains untested on real device.
> ---
> sound/usb/caiaq/input.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/sound/usb/caiaq/input.c b/sound/usb/caiaq/input.c
> index 1e2cf2f08eec..84f26dce7f5d 100644
> --- a/sound/usb/caiaq/input.c
> +++ b/sound/usb/caiaq/input.c
> @@ -804,6 +804,7 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *cdev)
>
> default:
> /* no input methods supported on this device */
> + ret = -EINVAL;
> goto exit_free_idev;
> }
>

2023-05-04 07:57:41

by Takashi Iwai

[permalink] [raw]
Subject: Re: [PATCH] sound: caiaq: input: Add error handling for unsupported input methods in `snd_usb_caiaq_input_init`

On Thu, 04 May 2023 08:50:53 +0200,
Ruliang Lin wrote:
>
> Smatch complains that:
> snd_usb_caiaq_input_init() warn: missing error code 'ret'
>
> This patch adds a new case to handle the situation where the
> device does not support any input methods in the
> `snd_usb_caiaq_input_init` function. It returns an `-EINVAL` error code
> to indicate that no input methods are supported on the device.
>
> Fixes: 523f1dce3743 ("[ALSA] Add Native Instrument usb audio device support")
> Signed-off-by: Ruliang Lin <[email protected]>
> Reviewed-by: Dongliang Mu <[email protected]>
> ---
> The issue is found by static analyzer. The patched code has passed
> Smatch checker, but remains untested on real device.

Thanks, applied.


Takashi