Skip to content

Commit 8d19a7a

Browse files
Radon10043gregkh
authored andcommitted
ALSA: usb-audio: Fix NULL pointer deference in try_to_register_card
[ Upstream commit 28412b4 ] 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: 39efc9c ("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>
1 parent d18c1b5 commit 8d19a7a

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

sound/usb/card.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -753,10 +753,16 @@ get_alias_quirk(struct usb_device *dev, unsigned int id)
753753
*/
754754
static int try_to_register_card(struct snd_usb_audio *chip, int ifnum)
755755
{
756+
struct usb_interface *iface;
757+
756758
if (check_delayed_register_option(chip) == ifnum ||
757-
chip->last_iface == ifnum ||
758-
usb_interface_claimed(usb_ifnum_to_if(chip->dev, chip->last_iface)))
759+
chip->last_iface == ifnum)
760+
return snd_card_register(chip->card);
761+
762+
iface = usb_ifnum_to_if(chip->dev, chip->last_iface);
763+
if (iface && usb_interface_claimed(iface))
759764
return snd_card_register(chip->card);
765+
760766
return 0;
761767
}
762768

0 commit comments

Comments
 (0)