]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ALSA: usb: scarlett2: Fix missing NULL check
authorTakashi Iwai <tiwai@suse.de>
Thu, 31 Jul 2025 05:37:08 +0000 (07:37 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 15 Aug 2025 14:39:13 +0000 (16:39 +0200)
[ Upstream commit df485a4b2b3ee5b35c80f990beb554e38a8a5fb1 ]

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: 8eba063b5b2b ("ALSA: scarlett2: Simplify linked channel handling")
Link: https://patch.msgid.link/20250731053714.29414-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
sound/usb/mixer_scarlett2.c

index 93589e86828a3e7a8ebf455a6a498a6e5f4e26a3..c137e44f8f8c1d2de8b596aacd88a3900b4eb804 100644 (file)
@@ -3971,8 +3971,13 @@ static int scarlett2_input_select_ctl_info(
                goto unlock;
 
        /* Loop through each input */
-       for (i = 0; i < inputs; i++)
+       for (i = 0; i < inputs; i++) {
                values[i] = kasprintf(GFP_KERNEL, "Input %d", i + 1);
+               if (!values[i]) {
+                       err = -ENOMEM;
+                       goto unlock;
+               }
+       }
 
        err = snd_ctl_enum_info(uinfo, 1, i,
                                (const char * const *)values);