public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix OOPS in pl2303
@ 2009-06-16  7:42 Vitaly Mayatskikh
  2009-06-16 18:26 ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Vitaly Mayatskikh @ 2009-06-16  7:42 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman

Kernel always OOPS in pl2303_close(), when serial converter disappears
and pppd tries to close statistics files in sysfs, because priv
structure was already freed in pl2302_shutdown().

This patch adds check for priv in pl2303_close().

Signed-off-by: Vitaly Mayatskikh <v.mayatskih@gmail.com>

diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index e02dc3d..945cfb0 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -674,19 +674,19 @@ static void pl2303_close(struct usb_serial_port *port)
 	struct pl2303_private *priv = usb_get_serial_port_data(port);
 	unsigned long flags;
 
-	dbg("%s - port %d", __func__, port->number);
-
-	spin_lock_irqsave(&priv->lock, flags);
-	/* clear out any remaining data in the buffer */
-	pl2303_buf_clear(priv->buf);
-	spin_unlock_irqrestore(&priv->lock, flags);
+	if (priv) {
+		dbg("%s - port %d", __func__, port->number);
 
+		spin_lock_irqsave(&priv->lock, flags);
+		/* clear out any remaining data in the buffer */
+		pl2303_buf_clear(priv->buf);
+		spin_unlock_irqrestore(&priv->lock, flags);
+	}
 	/* shutdown our urbs */
 	dbg("%s - shutting down urbs", __func__);
 	usb_kill_urb(port->write_urb);
 	usb_kill_urb(port->read_urb);
 	usb_kill_urb(port->interrupt_in_urb);
-
 }
 
 static int pl2303_open(struct tty_struct *tty,

-- 
wbr, Vitaly

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-06-18  5:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-16  7:42 [PATCH] Fix OOPS in pl2303 Vitaly Mayatskikh
2009-06-16 18:26 ` Greg KH
2009-06-17  1:36   ` Vitaly Mayatskikh
2009-06-17 13:41     ` Greg KH
2009-06-18  5:12       ` Vitaly Mayatskikh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox