diff options
author | Amit Shah <amit.shah@redhat.com> | 2013-08-07 02:24:17 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2013-08-08 23:32:16 -0400 |
commit | 3b868a4073cdedf395f26d843874414e0e0e9cfd (patch) | |
tree | c61396970bcaa517abe6511dda51914737a8dfd3 | |
parent | 11489736177c5930514482b4db7af862d945335d (diff) |
virtio: console: prevent use-after-free of port name in port unplug
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>
-rw-r--r-- | drivers/char/virtio_console.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index d0e75aa904ac..b79cf3e1b793 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c | |||
@@ -1591,9 +1591,8 @@ static void unplug_port(struct port *port) | |||
1591 | device_destroy(pdrvdata.class, port->dev->devt); | 1591 | device_destroy(pdrvdata.class, port->dev->devt); |
1592 | cdev_del(port->cdev); | 1592 | cdev_del(port->cdev); |
1593 | 1593 | ||
1594 | kfree(port->name); | ||
1595 | |||
1596 | debugfs_remove(port->debugfs_file); | 1594 | debugfs_remove(port->debugfs_file); |
1595 | kfree(port->name); | ||
1597 | 1596 | ||
1598 | /* | 1597 | /* |
1599 | * Locks around here are not necessary - a port can't be | 1598 | * Locks around here are not necessary - a port can't be |