Make sure to wake up any process sleeping on the modem-status-change
queue at port remove.

Currently a process waiting on modem status changes will not
necessarily be woken on device disconnect.

Note that we need to use the disconnected flag to detect disconnect as
the port private data may have been freed when woken up.

Also remove bogus test for private data pointer being NULL as it is
never assigned in the loop.

Cc: stable <sta...@vger.kernel.org>
Signed-off-by: Johan Hovold <jhov...@gmail.com>
---
 drivers/usb/serial/cypress_m8.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c
index 8efa19d..67ca609 100644
--- a/drivers/usb/serial/cypress_m8.c
+++ b/drivers/usb/serial/cypress_m8.c
@@ -556,6 +556,8 @@ static int cypress_port_remove(struct usb_serial_port *port)
 {
        struct cypress_private *priv;
 
+       wake_up_interruptible(&priv->delta_msr_wait);
+
        priv = usb_get_serial_port_data(port);
 
        kfifo_free(&priv->write_fifo);
@@ -868,15 +870,17 @@ static int cypress_ioctl(struct tty_struct *tty,
        switch (cmd) {
        /* This code comes from drivers/char/serial.c and ftdi_sio.c */
        case TIOCMIWAIT:
-               while (priv != NULL) {
+               for (;;) {
                        interruptible_sleep_on(&priv->delta_msr_wait);
                        /* see if a signal did it */
                        if (signal_pending(current))
                                return -ERESTARTSYS;
-                       else {
+
+                       if (port->serial->disconnected)
+                               return -EIO;
+
+                       {
                                char diff = priv->diff_status;
-                               if (diff == 0)
-                                       return -EIO; /* no change => error */
 
                                /* consume all events */
                                priv->diff_status = 0;
-- 
1.8.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to