]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
ALSA: usb-audio: Fix incorrect NULL check in create_yamaha_midi_quirk()
authorTakashi Iwai <tiwai@suse.de>
Wed, 13 Nov 2019 11:12:59 +0000 (12:12 +0100)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 4 Dec 2019 09:29:26 +0000 (10:29 +0100)
BugLink: https://bugs.launchpad.net/bugs/1853475
commit cc9dbfa9707868fb0ca864c05e0c42d3f4d15cf2 upstream.

The commit 60849562a5db ("ALSA: usb-audio: Fix possible NULL
dereference at create_yamaha_midi_quirk()") added NULL checks in
create_yamaha_midi_quirk(), but there was an overlook.  The code
allows one of either injd or outjd is NULL, but the second if check
made returning -ENODEV if any of them is NULL.  Fix it in a proper
form.

Fixes: 60849562a5db ("ALSA: usb-audio: Fix possible NULL dereference at create_yamaha_midi_quirk()")
Reported-by: Pavel Machek <pavel@denx.de>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20191113111259.24123-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Connor Kuehl <connor.kuehl@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
sound/usb/quirks.c

index 0bbe1201a6ac8c57c7ae533e516c92fe67f832a7..349e1e52996d8924c812f0177998d45fee970950 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 (!(injd && snd_usb_validate_midi_desc(injd)) ||
-           !(outjd && 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 &&