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>
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index 4e380c1..e910bec 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c
@@ -1574,9 +1574,8 @@ 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