can: gs_usb: gs_destroy_candev(): fix use after free
authorMarc Kleine-Budde <mkl@pengutronix.de>
Wed, 21 May 2014 08:06:02 +0000 (10:06 +0200)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Wed, 21 May 2014 11:04:20 +0000 (13:04 +0200)
This patch fixes a use after free of "dev" in gs_destroy_candev().

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
drivers/net/can/usb/gs_usb.c

index c9f1f99682b1f1dda23550c7e2cb9e609f23c0bb..04b0f84612f0cf12fd1cfc59925a60c448423fa2 100644 (file)
@@ -826,8 +826,8 @@ static void gs_destroy_candev(struct gs_can *dev)
 {
        unregister_candev(dev->netdev);
        free_candev(dev->netdev);
-       kfree(dev);
        usb_kill_anchored_urbs(&dev->tx_submitted);
+       kfree(dev);
 }
 
 static int gs_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)