ALSA: usb-audio: Fix possible NULL dereference at create_yamaha_midi_quirk()
authorTakashi Iwai <tiwai@suse.de>
Mon, 26 Aug 2019 11:55:21 +0000 (13:55 +0200)
committerTakashi Iwai <tiwai@suse.de>
Mon, 26 Aug 2019 11:55:21 +0000 (13:55 +0200)
The previous addition of descriptor validation may lead to a NULL
dereference at create_yamaha_midi_quirk() when either injd or outjd is
NULL.  Add proper non-NULL checks.

Fixes: 57f8770620e9 ("ALSA: usb-audio: More validations of descriptor units")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/usb/quirks.c

index 7e9735aa7ac91fe2fc9c98e210d925bfdb772c73..5c0fa5cf19877213d7f7c542f2244238c85331c5 100644 (file)
@@ -248,8 +248,8 @@ static int create_yamaha_midi_quirk(struct snd_usb_audio *chip,
                                        NULL, USB_MS_MIDI_OUT_JACK);
        if (!injd && !outjd)
                return -ENODEV;
-       if (!snd_usb_validate_midi_desc(injd) ||
-           !snd_usb_validate_midi_desc(outjd))
+       if (!(injd && snd_usb_validate_midi_desc(injd)) ||
+           !(outjd && snd_usb_validate_midi_desc(outjd)))
                return -ENODEV;
        if (injd && (injd->bLength < 5 ||
                     (injd->bJackType != USB_MS_EMBEDDED &&