[PATCH v2 03/15] USB: cypress_m8: fix TIOCMIWAIT and disconnect

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <stable@xxxxxxxxxxxxxxx>
Signed-off-by: Johan Hovold <jhovold@xxxxxxxxx>
---
 drivers/usb/serial/cypress_m8.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c
index 8efa19d..dd4d17f 100644
--- a/drivers/usb/serial/cypress_m8.c
+++ b/drivers/usb/serial/cypress_m8.c
@@ -557,7 +557,7 @@ static int cypress_port_remove(struct usb_serial_port *port)
 	struct cypress_private *priv;
 
 	priv = usb_get_serial_port_data(port);
-
+	wake_up_interruptible(&priv->delta_msr_wait);
 	kfifo_free(&priv->write_fifo);
 	kfree(priv);
 
@@ -868,15 +868,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 stable" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]