list_del(&port->list);
        spin_unlock_irq(&port->portdev->ports_lock);
  
 +      spin_lock_irq(&port->inbuf_lock);
        if (port->guest_connected) {
+               /* Let the app know the port is going down. */
+               send_sigio_to_port(port);
+ 
+               /* Do this after sigio is actually sent */
                port->guest_connected = false;
                port->host_connected = false;
-               wake_up_interruptible(&port->waitqueue);
  
-               /* Let the app know the port is going down. */
-               send_sigio_to_port(port);
+               wake_up_interruptible(&port->waitqueue);
        }
 +      spin_unlock_irq(&port->inbuf_lock);
  
        if (is_console_port(port)) {
                spin_lock_irq(&pdrvdata_lock);