]> git.hungrycats.org Git - linux/commitdiff
ALSA: control: Don't add invalid kcontrols to LED layer
authorTakashi Iwai <tiwai@suse.de>
Thu, 27 Aug 2026 11:39:03 +0000 (13:39 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 14 Sep 2026 11:36:14 +0000 (13:36 +0200)
[ Upstream commit 74e3b979ce8b78a690f8b94ccf2e2c965f7f5c11 ]

The kcontrol LED state layer tries to track the all associated
kcontrol elements with naive assumptions that they are readable.
But one can create a write-only element that has no get callback (even
a user element can do it), and this may lead to a NULL dereference at
the call chain of snd_ctl_led_notify(), as found by syzkaller.

For avoiding the Oops, add a sanity check of the kcontrol's info and
get callbacks, and just skip the invalid kcontrols before assigning
the kctl to the LED layer.

Reported-by: syzbot+b7fe2760ea6f1ee44b4d@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/6a9007b3.1d9ded08.62e62.00cd.GAE@google.com
Fixes: 22d8de62f11b ("ALSA: control - add generic LED trigger module as the new control layer")
Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20260827113951.893291-1-tiwai@suse.de
Signed-off-by: Sasha Levin <sashal@kernel.org>
sound/core/control_led.c

index 007aba163236c5aba093a9373a091e1861ce2d28..ae903af93dd327536294e86e40b33b2039bdaa16 100644 (file)
@@ -255,6 +255,8 @@ static int snd_ctl_led_set_id(int card_number, struct snd_ctl_elem_id *id,
        kctl = snd_ctl_find_id(card, id);
        if (!kctl)
                return -ENOENT;
+       if (!kctl->info || !kctl->get)
+               return -EINVAL;
        ioff = snd_ctl_get_ioff(kctl, id);
        vd = &kctl->vd[ioff];
        access = vd->access & SNDRV_CTL_ELEM_ACCESS_LED_MASK;