virtio: console: add locking in port unplug path
authorAmit Shah <amit.shah@redhat.com>
Mon, 29 Jul 2013 04:54:15 +0000 (14:24 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Mon, 29 Jul 2013 05:20:48 +0000 (14:50 +0930)
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>
drivers/char/virtio_console.c

index 601962b1708b8367c244cc7728651bcf788590ed..3572c5a92e8e487fd5ae9fd32b920ceffa768d93 100644 (file)
@@ -1542,6 +1542,7 @@ static void unplug_port(struct port *port)
        list_del(&port->list);
        spin_unlock_irq(&port->portdev->ports_lock);
 
+       spin_lock_irq(&port->inbuf_lock);
        if (port->guest_connected) {
                port->guest_connected = false;
                port->host_connected = false;
@@ -1550,6 +1551,7 @@ static void unplug_port(struct port *port)
                /* Let the app know the port is going down. */
                send_sigio_to_port(port);
        }
+       spin_unlock_irq(&port->inbuf_lock);
 
        if (is_console_port(port)) {
                spin_lock_irq(&pdrvdata_lock);
This page took 0.033105 seconds and 5 git commands to generate.