aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorAmit Shah <amit.shah@redhat.com>2013-07-29 00:54:15 -0400
committerRusty Russell <rusty@rustcorp.com.au>2013-07-29 01:20:48 -0400
commit5549fb25811710585d5ec77a0e6a1fbc8808df93 (patch)
treece02bc03118f48b02baa4690d0dd057ff589fbb9 /drivers/char
parentc6017e793b932e84b1c998f9b4c08d74ff0ea9c0 (diff)
virtio: console: add locking in port unplug path
Port unplug can race with close() in port_fops_release(). port_fops_release() already takes the necessary locks, ensure unplug_port() does that too. Signed-off-by: Amit Shah <amit.shah@redhat.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/virtio_console.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 601962b1708b..3572c5a92e8e 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -1542,6 +1542,7 @@ static void unplug_port(struct port *port)
1542 list_del(&port->list); 1542 list_del(&port->list);
1543 spin_unlock_irq(&port->portdev->ports_lock); 1543 spin_unlock_irq(&port->portdev->ports_lock);
1544 1544
1545 spin_lock_irq(&port->inbuf_lock);
1545 if (port->guest_connected) { 1546 if (port->guest_connected) {
1546 port->guest_connected = false; 1547 port->guest_connected = false;
1547 port->host_connected = false; 1548 port->host_connected = false;
@@ -1550,6 +1551,7 @@ static void unplug_port(struct port *port)
1550 /* Let the app know the port is going down. */ 1551 /* Let the app know the port is going down. */
1551 send_sigio_to_port(port); 1552 send_sigio_to_port(port);
1552 } 1553 }
1554 spin_unlock_irq(&port->inbuf_lock);
1553 1555
1554 if (is_console_port(port)) { 1556 if (is_console_port(port)) {
1555 spin_lock_irq(&pdrvdata_lock); 1557 spin_lock_irq(&pdrvdata_lock);