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-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 5 Aug 2013 18:40:13 +0100
From:	Rupesh Gujare <rupesh.gujare@...el.com>
To:	<devel@...uxdriverproject.org>
CC:	<linux-usb@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
	<gregkh@...uxfoundation.org>
Subject: [PATCH 2/4] staging: ozwpan: Increment port number for new device.

This patch fixes crash issue when there is quick cycle of
de-enumeration & enumeration due to loss of wireless link.

It is found that sometimes new device (or coming back device)
returns very fast, even before USB core read out hub status,
resulting in allocation of same port, which results in unstable
system & crash.

Above issue is resolved by making sure that we always assign
new port to new device, making sure that USB core reads correct
hub status.

Signed-off-by: Rupesh Gujare <rupesh.gujare@...el.com>
---
 drivers/staging/ozwpan/ozhcd.c |   16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c
index d313a63..a739986 100644
--- a/drivers/staging/ozwpan/ozhcd.c
+++ b/drivers/staging/ozwpan/ozhcd.c
@@ -127,6 +127,7 @@ struct oz_hcd {
 	struct list_head urb_cancel_list;
 	struct list_head orphanage;
 	int conn_port; /* Port that is currently connecting, -1 if none.*/
+	int last_port;
 	struct oz_port ports[OZ_NB_PORTS];
 	uint flags;
 	struct usb_hcd *hcd;
@@ -645,7 +646,9 @@ void *oz_hcd_pd_arrived(void *hpd)
 		goto out;
 	}
 	for (i = 0; i < OZ_NB_PORTS; i++) {
-		struct oz_port *port = &ozhcd->ports[i];
+		struct oz_port *port = &ozhcd->ports[ozhcd->last_port++];
+		if (ozhcd->last_port >= OZ_NB_PORTS)
+			ozhcd->last_port = 0;
 		spin_lock(&port->port_lock);
 		if ((port->flags & OZ_PORT_F_PRESENT) == 0) {
 			oz_acquire_port(port, hpd);
@@ -655,13 +658,16 @@ void *oz_hcd_pd_arrived(void *hpd)
 		spin_unlock(&port->port_lock);
 	}
 	if (i < OZ_NB_PORTS) {
-		oz_dbg(ON, "Setting conn_port = %d\n", i);
-		ozhcd->conn_port = i;
+		if (!ozhcd->last_port)
+			ozhcd->conn_port = OZ_NB_PORTS - 1;
+		else
+			ozhcd->conn_port = ozhcd->last_port - 1;
+		oz_dbg(ON, "Setting conn_port = %d\n", ozhcd->conn_port);
 		/* Attach out endpoint 0.
 		 */
-		ozhcd->ports[i].out_ep[0] = ep;
+		ozhcd->ports[ozhcd->conn_port].out_ep[0] = ep;
 		ep = NULL;
-		hport = &ozhcd->ports[i];
+		hport = &ozhcd->ports[ozhcd->conn_port];
 		spin_unlock_bh(&ozhcd->hcd_lock);
 		if (ozhcd->flags & OZ_HDC_F_SUSPENDED) {
 			oz_dbg(ON, "Resuming root hub\n");
-- 
1.7.9.5

--
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