[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <87k53cy697.wl%vmayatsk@redhat.com>
Date:	Tue, 16 Jun 2009 09:42:12 +0200
From:	Vitaly Mayatskikh <v.mayatskih@...il.com>
To:	linux-kernel@...r.kernel.org
Cc:	Greg Kroah-Hartman <greg@...ah.com>
Subject: [PATCH] Fix OOPS in pl2303
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@...il.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
--
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