can: usb_8dev: fix use-after-free on disconnect
authorJohan Hovold <johan@kernel.org>
Tue, 1 Oct 2019 10:29:14 +0000 (12:29 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 12 Nov 2019 18:20:43 +0000 (19:20 +0100)
commit 3759739426186a924675651b388d1c3963c5710e upstream.

The driver was accessing its driver data after having freed it.

Fixes: 0024d8ad1639 ("can: usb_8dev: Add support for USB2CAN interface from 8 devices")
Cc: stable <stable@vger.kernel.org> # 3.9
Cc: Bernd Krumboeck <b.krumboeck@gmail.com>
Cc: Wolfgang Grandegger <wg@grandegger.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/can/usb/usb_8dev.c

index 27861c4..3e44164 100644 (file)
@@ -1007,9 +1007,8 @@ static void usb_8dev_disconnect(struct usb_interface *intf)
                netdev_info(priv->netdev, "device disconnected\n");
 
                unregister_netdev(priv->netdev);
-               free_candev(priv->netdev);
-
                unlink_all_urbs(priv);
+               free_candev(priv->netdev);
        }
 
 }