diff options
| author | Jiaming Zhang <r772577952@gmail.com> | 2025-10-15 13:16:45 +0800 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-10-23 16:20:37 +0200 |
| commit | bba7208765d26e5e36b87f21dacc2780b064f41f (patch) | |
| tree | 90e769fd4ba057c0fee49442d4b3520ff8c01e54 /sound | |
| parent | c1bcd7205ac365a341149d0c5d73c8152289caf1 (diff) | |
| download | linux-bba7208765d26e5e36b87f21dacc2780b064f41f.tar.gz linux-bba7208765d26e5e36b87f21dacc2780b064f41f.tar.bz2 linux-bba7208765d26e5e36b87f21dacc2780b064f41f.zip | |
ALSA: usb-audio: Fix NULL pointer deference in try_to_register_card
[ Upstream commit 28412b489b088fb88dff488305fd4e56bd47f6e4 ]
In try_to_register_card(), the return value of usb_ifnum_to_if() is
passed directly to usb_interface_claimed() without a NULL check, which
will lead to a NULL pointer dereference when creating an invalid
USB audio device. Fix this by adding a check to ensure the interface
pointer is valid before passing it to usb_interface_claimed().
Fixes: 39efc9c8a973 ("ALSA: usb-audio: Fix last interface check for registration")
Closes: https://lore.kernel.org/all/CANypQFYtQxHL5ghREs-BujZG413RPJGnO5TH=xjFBKpPts33tA@mail.gmail.com/
Signed-off-by: Jiaming Zhang <r772577952@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'sound')
| -rw-r--r-- | sound/usb/card.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/sound/usb/card.c b/sound/usb/card.c index 9c411b82a218..d0a42859208a 100644 --- a/sound/usb/card.c +++ b/sound/usb/card.c @@ -760,10 +760,16 @@ get_alias_quirk(struct usb_device *dev, unsigned int id) */ static int try_to_register_card(struct snd_usb_audio *chip, int ifnum) { + struct usb_interface *iface; + if (check_delayed_register_option(chip) == ifnum || - chip->last_iface == ifnum || - usb_interface_claimed(usb_ifnum_to_if(chip->dev, chip->last_iface))) + chip->last_iface == ifnum) + return snd_card_register(chip->card); + + iface = usb_ifnum_to_if(chip->dev, chip->last_iface); + if (iface && usb_interface_claimed(iface)) return snd_card_register(chip->card); + return 0; } |
