virtio: console: prevent use-after-free of port name in port unplug
authorAmit Shah <amit.shah@redhat.com>
Wed, 7 Aug 2013 06:24:17 +0000 (15:54 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Fri, 9 Aug 2013 03:32:16 +0000 (13:02 +0930)
Remove the debugfs path before freeing port->name, to prevent a possible
use-after-free.

Reported-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
drivers/char/virtio_console.c

index d0e75aa904ac92dc1f53973a7b274a039dc45b46..b79cf3e1b793dca8f652067718d4ece3c0b3335d 100644 (file)
@@ -1591,9 +1591,8 @@ static void unplug_port(struct port *port)
        device_destroy(pdrvdata.class, port->dev->devt);
        cdev_del(port->cdev);
 
-       kfree(port->name);
-
        debugfs_remove(port->debugfs_file);
+       kfree(port->name);
 
        /*
         * Locks around here are not necessary - a port can't be