6pack: Fix use after free in sixpack_close().
authorDavid Miller <davem@davemloft.net>
Thu, 17 Dec 2015 21:05:32 +0000 (16:05 -0500)
committerDavid S. Miller <davem@davemloft.net>
Fri, 18 Dec 2015 20:57:33 +0000 (15:57 -0500)
Need to do the unregister_device() after all references to the driver
private have been done.

Also we need to use del_timer_sync() for the timers so that we don't
have any asynchronous references after the unregister.

Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/hamradio/6pack.c

index 7c4a415..9f0b1c3 100644 (file)
@@ -683,14 +683,14 @@ static void sixpack_close(struct tty_struct *tty)
        if (!atomic_dec_and_test(&sp->refcnt))
                down(&sp->dead_sem);
 
-       unregister_netdev(sp->dev);
-
-       del_timer(&sp->tx_t);
-       del_timer(&sp->resync_t);
+       del_timer_sync(&sp->tx_t);
+       del_timer_sync(&sp->resync_t);
 
        /* Free all 6pack frame buffers. */
        kfree(sp->rbuff);
        kfree(sp->xbuff);
+
+       unregister_netdev(sp->dev);
 }
 
 /* Perform I/O control on an active 6pack channel. */