Skip to contentSkip to conversation

sound: caiaq: input: Add error handling for unsupported input methods in `snd_usb_caiaq_input_init`

PATCH Applied Ruliang Lin 3 participants 3 messages May 4, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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")

---
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(+)
sound/usb/caiaq/input.c +1 -0
index 1e2cf2f08eec..84f26dce7f5d 100644
@@ -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;
 	}
 
Signature · 1 line
2.25.1
Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · Ruliang Lin

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")
Quoted 19 lines

---
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(+)
sound/usb/caiaq/input.c +1 -0
index 1e2cf2f08eec..84f26dce7f5d 100644
@@ -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;
 	}
 
Applied
#2 lore raw
In reply to Ruliang Lin
Quoted 9 lines · Ruliang Lin

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.

Quoted 6 lines
Fixes 523f1dce3743 ("[ALSA] Add Native Instrument usb audio device support")

---
The issue is found by static analyzer. The patched code has passed Smatch checker, but remains untested on real device.

Thanks, applied.

Takashi