Skip to content

Commit

Permalink
virtio: console: prevent use-after-free of port name in port unplug
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Amit Shah authored and Rusty Russell committed Aug 9, 2013
1 parent 1148973 commit 3b868a4
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions drivers/char/virtio_console.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3b868a4

Please sign in to comment.