USB: usb-skeleton: fix use-after-free after driver unbind
authorJohan Hovold <johan@kernel.org>
Wed, 9 Oct 2019 17:09:43 +0000 (19:09 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Oct 2019 10:41:19 +0000 (12:41 +0200)
The driver failed to stop its read URB on disconnect, something which
could lead to a use-after-free in the completion handler after driver
unbind in case the character device has been closed.

Fixes: e7389cc9a7ff ("USB: skel_read really sucks royally")
Signed-off-by: Johan Hovold <johan@kernel.org>
Link: https://lore.kernel.org/r/20191009170944.30057-3-johan@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/usb-skeleton.c

index c2843fcfa52dda002a251b65fe250b96ecf77167..be311787403eb42cc7fb22edc77d3ab7f92925ab 100644 (file)
@@ -575,6 +575,7 @@ static void skel_disconnect(struct usb_interface *interface)
        dev->disconnected = 1;
        mutex_unlock(&dev->io_mutex);
 
+       usb_kill_urb(dev->bulk_in_urb);
        usb_kill_anchored_urbs(&dev->submitted);
 
        /* decrement our usage count */