public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Vitaly Mayatskikh <v.mayatskih@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <greg@kroah.com>
Subject: [PATCH] Fix OOPS in pl2303
Date: Tue, 16 Jun 2009 09:42:12 +0200	[thread overview]
Message-ID: <87k53cy697.wl%vmayatsk@redhat.com> (raw)

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

             reply	other threads:[~2009-06-16  7:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-16  7:42 Vitaly Mayatskikh [this message]
2009-06-16 18:26 ` [PATCH] Fix OOPS in pl2303 Greg KH
2009-06-17  1:36   ` Vitaly Mayatskikh
2009-06-17 13:41     ` Greg KH
2009-06-18  5:12       ` Vitaly Mayatskikh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k53cy697.wl%vmayatsk@redhat.com \
    --to=v.mayatskih@gmail.com \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox