virtio: console: Fix crash when port is unplugged and blocked for write
authorAmit Shah <amit.shah@redhat.com>
Thu, 27 May 2010 07:54:40 +0000 (13:24 +0530)
committerRusty Russell <rusty@rustcorp.com.au>
Thu, 3 Jun 2010 13:09:19 +0000 (22:39 +0930)
When a program that has a virtio port opened and blocked for a write
operation, a port hot-unplug event will later led to a crash when
SIGTERM was sent to the program. Fix that.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
drivers/char/virtio_console.c

index e3fb5296cf25921f8ded676beed459b2a4191926..942a9826bd23ed64b83095fcdeb65ed059c9ce02 100644 (file)
@@ -529,6 +529,10 @@ static bool will_write_block(struct port *port)
 {
        bool ret;
 
+       if (!port->guest_connected) {
+               /* Port got hot-unplugged. Let's exit. */
+               return false;
+       }
        if (!port->host_connected)
                return true;