virtio: console: fix race with port unplug and open/close
authorAmit Shah <amit.shah@redhat.com>
Mon, 29 Jul 2013 04:46:13 +0000 (14:16 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Mon, 29 Jul 2013 05:13:28 +0000 (14:43 +0930)
commit057b82be3ca3d066478e43b162fc082930a746c9
tree8ca217f1b7c0e48a21540cb38779cc7a48216535
parent2b4fbf029dff5a28d9bf646346dea891ec43398a
virtio: console: fix race with port unplug and open/close

There's a window between find_port_by_devt() returning a port and us
taking a kref on the port, where the port could get unplugged.  Fix it
by taking the reference in find_port_by_devt() itself.

Problem reported and analyzed by Mateusz Guzik.

CC: <stable@vger.kernel.org>
Reported-by: Mateusz Guzik <mguzik@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