lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Sat, 19 Sep 2009 18:03:47 +0200
From:	Johan Hovold <jhovold@...il.com>
To:	Greg KH <greg@...ah.com>
Cc:	Alan Cox <alan@...rguk.ukuu.org.uk>,
	Alan Stern <stern@...land.harvard.edu>,
	linux-usb@...r.kernel.org, e9hack <e9hack@...glemail.com>,
	linux-kernel@...r.kernel.org
Subject: [PATCH] USB: ftdi_sio: Fix read regression in 2.6.31.

Use ASYNCB_INITIALIZED to determine when to stop reading.

Since 335f8514f200e63d689113d29cb7253a5c282967 port count can no longer
be used to determine when to stop reading from the device as it can be
zero when the first read callbacks are made (see tty_port_block_til_read
where port count is temporarily decremented during serial_open).

This fixes the regression where reads fail after connecting the device
and opening the port more than once (reads usually succeed after the
first open due to the device latency timer then being set to the default
16ms rather than 1ms).

Signed-off-by: Johan Hovold <jhovold@...il.com>
---

Tested against 2.6.31 as well as Greg's patch set
(f9752c181c0f7d8bc9c16df0124bf06c5a4d4d88).

Note that ASYNCB_INITIALIZED does not yet get cleared on close in
2.6.31 (as it does in Greg's patches), but ftdi_close kills the urb so
the driver stops reading at the next callback as the urb status then is
non-zero.

Regards,
Johan


 drivers/usb/serial/ftdi_sio.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 4f883b1..7eaea14 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -2033,7 +2033,7 @@ static void ftdi_read_bulk_callback(struct urb *urb)
 
 	dbg("%s - port %d", __func__, port->number);
 
-	if (port->port.count <= 0)
+	if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags))
 		return;
 
 	tty = tty_port_tty_get(&port->port);
@@ -2089,7 +2089,7 @@ static void ftdi_process_read(struct work_struct *work)
 
 	dbg("%s - port %d", __func__, port->number);
 
-	if (port->port.count <= 0)
+	if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags))
 		return;
 
 	tty = tty_port_tty_get(&port->port);
@@ -2247,7 +2247,7 @@ static void ftdi_process_read(struct work_struct *work)
 		}
 		spin_unlock_irqrestore(&priv->rx_lock, flags);
 		/* if the port is closed stop trying to read */
-		if (port->port.count > 0)
+		if (test_bit(ASYNCB_INITIALIZED, &port->port.flags))
 			/* delay processing of remainder */
 			schedule_delayed_work(&priv->rx_work, 1);
 		else
@@ -2259,7 +2259,7 @@ static void ftdi_process_read(struct work_struct *work)
 	priv->rx_processed = 0;
 
 	/* if the port is closed stop trying to read */
-	if (port->port.count > 0) {
+	if (test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
 		/* Continue trying to always read  */
 		usb_fill_bulk_urb(port->read_urb, port->serial->dev,
 			usb_rcvbulkpipe(port->serial->dev,
-- 
1.6.4.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ