diff options
author | Takashi Iwai <tiwai@suse.de> | 2025-07-31 07:37:08 +0200 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2025-07-31 17:04:28 +0200 |
commit | df485a4b2b3ee5b35c80f990beb554e38a8a5fb1 (patch) | |
tree | f14a043a636b5330b357879c373763b7555c5e39 | |
parent | 5e0753df9623559542404e167172ba97e412f45e (diff) |
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: 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>
-rw-r--r-- | sound/usb/mixer_scarlett2.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/sound/usb/mixer_scarlett2.c b/sound/usb/mixer_scarlett2.c index 15bbdafc4894..1ec203cbbd94 100644 --- a/sound/usb/mixer_scarlett2.c +++ b/sound/usb/mixer_scarlett2.c @@ -3978,8 +3978,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); |