Skip to content

Commit df485a4

Browse files
committed
ALSA: usb: scarlett2: Fix missing NULL check
scarlett2_input_select_ctl_info() sets up the string arrays allocated via kasprintf(), but it misses NULL checks, which may lead to NULL dereference Oops. Let's add the proper NULL check. Fixes: 8eba063 ("ALSA: scarlett2: Simplify linked channel handling") Link: https://patch.msgid.link/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 5e0753d commit df485a4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

sound/usb/mixer_scarlett2.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3978,8 +3978,13 @@ static int scarlett2_input_select_ctl_info(
39783978
goto unlock;
39793979

39803980
/* Loop through each input */
3981-
for (i = 0; i < inputs; i++)
3981+
for (i = 0; i < inputs; i++) {
39823982
values[i] = kasprintf(GFP_KERNEL, "Input %d", i + 1);
3983+
if (!values[i]) {
3984+
err = -ENOMEM;
3985+
goto unlock;
3986+
}
3987+
}
39833988

39843989
err = snd_ctl_enum_info(uinfo, 1, i,
39853990
(const char * const *)values);

0 commit comments

Comments
 (0)