diff mbox series

ALSA: usb-audio: Fix incorrect NULL check in create_yamaha_midi_quirk()

Message ID 20191113111259.24123-1-tiwai@suse.de (mailing list archive)
State New, archived
Headers show
Series ALSA: usb-audio: Fix incorrect NULL check in create_yamaha_midi_quirk() | expand

Commit Message

Takashi Iwai Nov. 13, 2019, 11:12 a.m. UTC
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>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/usb/quirks.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Pavel Machek Nov. 18, 2019, 2:34 p.m. UTC | #1
On Wed 2019-11-13 12:12:59, Takashi Iwai wrote:
> 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>
> Signed-off-by: Takashi Iwai <tiwai@suse.de>

Thanks for doing this.

Acked-by: Pavel Machek <pavel@denx.de>
								Pavel
diff mbox series

Patch

diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
index 0bbe1201a6ac..349e1e52996d 100644
--- a/sound/usb/quirks.c
+++ b/sound/usb/quirks.c
@@ -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 &&