Skip to content

Commit 2c735fc

Browse files
tiwaigregkh
authored andcommitted
ALSA: usb: scarlett2: Fix missing NULL check
[ Upstream commit df485a4 ] 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]> Signed-off-by: Sasha Levin <[email protected]>
1 parent fe3d235 commit 2c735fc

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
@@ -3971,8 +3971,13 @@ static int scarlett2_input_select_ctl_info(
39713971
goto unlock;
39723972

39733973
/* Loop through each input */
3974-
for (i = 0; i < inputs; i++)
3974+
for (i = 0; i < inputs; i++) {
39753975
values[i] = kasprintf(GFP_KERNEL, "Input %d", i + 1);
3976+
if (!values[i]) {
3977+
err = -ENOMEM;
3978+
goto unlock;
3979+
}
3980+
}
39763981

39773982
err = snd_ctl_enum_info(uinfo, 1, i,
39783983
(const char * const *)values);

0 commit comments

Comments
 (0)