ALSA: line6: Abort if inconsistent usbdev is found at disconnect
authorTakashi Iwai <tiwai@suse.de>
Tue, 20 Jan 2015 08:58:54 +0000 (09:58 +0100)
committerTakashi Iwai <tiwai@suse.de>
Wed, 28 Jan 2015 06:19:29 +0000 (07:19 +0100)
It's utterly unsafe to proceed further the disconnect procedure if the
assigned usbdev is inconsistent with the expected object.  Better to
put a WARN_ON() for more cautions and abort immediately.

Tested-by: Chris Rorvick <chris@rorvick.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/usb/line6/driver.c

index e8d51381ffdb7a4fc2aa354569e2742147915b3d..625272fe227a2cba073a930276e5e994874b6a9b 100644 (file)
@@ -585,12 +585,12 @@ void line6_disconnect(struct usb_interface *interface)
        if (!line6)
                return;
 
+       if (WARN_ON(usbdev != line6->usbdev))
+               return;
+
        if (line6->urb_listen != NULL)
                line6_stop_listen(line6);
 
-       if (usbdev != line6->usbdev)
-               dev_err(line6->ifcdev, "driver bug: inconsistent usb device\n");
-
        snd_card_disconnect(line6->card);
        if (line6->line6pcm)
                line6_pcm_disconnect(line6->line6pcm);