Skip to contentSkip to conversation

fix oops in usbserial_cleanup function;

PATCH In review [email protected] 2 participants 2 messages Oct 15, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix oops in usbserial_cleanup function;

From: marui <[email protected]>

1. I find this bug on OpenSUSE 11.3 which kernel vesion is 2.6.34, but the latest kernel vesion 2.6.36-rc7 aslo have this bug. This patch is based on the kernel of 2.6.36-rc7.
2. Bug report:
a. Install huawei datacard dashboard on OpenSUSE 11.3
b. Plug in huawei datacard into OpenSUSE 11.3 which kernel verison is 2.6.36-rc7
c. After the dashboard has detected the device, I pull out the usb datacard
d. close datashboard,then kernel panic will happen in usbserial_cleanup function.

3. fix the bug:
I find usbserial_cleanup should judge the usb device wheher has been disconnected firtly.

drivers/usb/serial/usb-serial.c +14 -0
@@ -328,6 +328,20 @@ static void serial_cleanup(struct tty_st
 	/* The console is magical.  Do not hang up the console hardware
 	 * or there will be tears.
 	 */
+        dbg("%s start\n",__func__);
+        if(NULL == port)
+        {
+            dbg("%s NULL == port\n",__func__);
+            return;
+        }
+	mutex_lock(&port->serial->disc_mutex);
+	if (port->serial->disconnected)
+        {
+                dbg("%s port->serial->disconnected\n",__func__);
+                return_serial(port->serial);
+		return;
+        }
+	mutex_unlock(&port->serial->disc_mutex);
 	if (port->port.console)
 		return;
 
#1 lore raw
Quoted 10 lines · On Fri, Oct 15, 2010 at 12:14:37PM +0800, [email protected] wrote:

From: marui <[email protected]>

1. I find this bug on OpenSUSE 11.3 which kernel vesion is 2.6.34, but the latest kernel vesion 2.6.36-rc7 aslo have this bug. This patch is based on the kernel of 2.6.36-rc7.
2. Bug report:
a. Install huawei datacard dashboard on OpenSUSE 11.3
b. Plug in huawei datacard into OpenSUSE 11.3 which kernel verison is 2.6.36-rc7
c. After the dashboard has detected the device, I pull out the usb datacard
d. close datashboard,then kernel panic will happen in usbserial_cleanup function.

Quoted 4 lines

3. fix the bug:
I find usbserial_cleanup should judge the usb device wheher has been disconnected firtly.

I need a full name here please.

drivers/usb/serial/usb-serial.c static void serial_cleanup(struct tty_st · line 337

Quoted 13 lines
drivers/usb/serial/usb-serial.c +7 -0
@@ -328,6 +328,20 @@ static void serial_cleanup(struct tty_st
 	/* The console is magical.  Do not hang up the console hardware
 	 * or there will be tears.
 	 */
+        dbg("%s start\n",__func__);
+        if(NULL == port)
+        {
+            dbg("%s NULL == port\n",__func__);
+            return;
+        }
+	mutex_lock(&port->serial->disc_mutex);

Please read Documentation/CodingStyle for the tabs and brace placements you need to resolve.

thanks,

greg k-h