public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Stefani Seibold <stefani@seibold.net>
To: linux-kernel <linux-kernel@vger.kernel.org>
Cc: Johan Hovold <jhovold@gmail.com>,
	Pete Zaitcev <zaitcev@redhat.com>, Greg KH <greg@kroah.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-usb@vger.kernel.org
Subject: [tip:urgent] fix USB serial fix kfifo_len locking
Date: Tue, 05 Jan 2010 14:30:31 +0100	[thread overview]
Message-ID: <1262698231.4532.4.camel@wall-e> (raw)
In-Reply-To: <1262692881.23577.15.camel@wall-e>

This patch fix a possible race bug in drivers/usb/serial/generic with
the new kfifo API.

Please apply it to the 2.6.33-rc* tree.

Signed-off-by: Stefani Seibold <stefani@seibold.net>
---
 generic.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

--- linux-2.6.33-rc2.orig/drivers/usb/serial/generic.c	2009-12-27 23:37:03.566060210 +0100
+++ linux-2.6.33-rc2.new/drivers/usb/serial/generic.c	2010-01-04 20:15:38.023351711 +0100
@@ -386,12 +386,12 @@ int usb_serial_generic_chars_in_buffer(s
 
 	dbg("%s - port %d", __func__, port->number);
 
-	if (serial->type->max_in_flight_urbs) {
-		spin_lock_irqsave(&port->lock, flags);
+	spin_lock_irqsave(&port->lock, flags);
+	if (serial->type->max_in_flight_urbs)
 		chars = port->tx_bytes_flight;
-		spin_unlock_irqrestore(&port->lock, flags);
-	} else if (serial->num_bulk_out)
+	else if (serial->num_bulk_out)
 		chars = kfifo_len(&port->write_fifo);
+	spin_unlock_irqrestore(&port->lock, flags);
 
 	dbg("%s - returns %d", __func__, chars);
 	return chars;



  parent reply	other threads:[~2010-01-05 13:30 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-04 17:43 USB: serial: kfifo_len locking Johan Hovold
2010-01-04 19:20 ` Stefani Seibold
2010-01-05  7:43   ` Pete Zaitcev
2010-01-05  7:51     ` Stefani Seibold
2010-01-05 11:04     ` Johan Hovold
2010-01-05 11:09       ` Stefani Seibold
2010-01-05 11:14         ` Johan Hovold
2010-01-05 11:25           ` Stefani Seibold
2010-01-05 11:35             ` Johan Hovold
2010-01-05 12:01               ` Stefani Seibold
2010-01-05 12:10                 ` Johan Hovold
2010-01-05 13:30                 ` Stefani Seibold [this message]
2010-01-05 14:32                   ` [tip:urgent] fix USB serial fix " Greg KH
2010-01-05 13:38                 ` [tip:urgent] fix kfifo_out_locked race bug Stefani Seibold
2010-01-08 23:18                   ` Andrew Morton
2010-01-05 17:00         ` USB: serial: kfifo_len locking Pete Zaitcev

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=1262698231.4532.4.camel@wall-e \
    --to=stefani@seibold.net \
    --cc=akpm@linux-foundation.org \
    --cc=greg@kroah.com \
    --cc=jhovold@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=zaitcev@redhat.com \
    /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