diff options
author | Jiri Kosina <jkosina@suse.cz> | 2007-10-19 18:05:19 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-10-25 15:18:45 -0400 |
commit | acd2a847e7fee7df11817f67dba75a2802793e5d (patch) | |
tree | 7eba6fe6c15f5f11ffdec779c9979f1ec6b4c6b9 /drivers/usb/serial | |
parent | 8a28dea3accda319d51a1bf4d3e280771d946f78 (diff) |
USB: usbserial - fix potential deadlock between write() and IRQ
USB: usbserial - fix potential deadlock between write() and IRQ
usb_serial_generic_write() doesn't disable interrupts when taking port->lock,
and could therefore deadlock with usb_serial_generic_read_bulk_callback()
being called from interrupt, taking the same lock. Fix it.
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Acked-by: Larry Finger <larry.finger@lwfinger.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/serial')
-rw-r--r-- | drivers/usb/serial/generic.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c index 88a2c7dce335..9eb4a65ee4d9 100644 --- a/drivers/usb/serial/generic.c +++ b/drivers/usb/serial/generic.c | |||
@@ -208,14 +208,15 @@ int usb_serial_generic_write(struct usb_serial_port *port, const unsigned char * | |||
208 | 208 | ||
209 | /* only do something if we have a bulk out endpoint */ | 209 | /* only do something if we have a bulk out endpoint */ |
210 | if (serial->num_bulk_out) { | 210 | if (serial->num_bulk_out) { |
211 | spin_lock_bh(&port->lock); | 211 | unsigned long flags; |
212 | spin_lock_irqsave(&port->lock, flags); | ||
212 | if (port->write_urb_busy) { | 213 | if (port->write_urb_busy) { |
213 | spin_unlock_bh(&port->lock); | 214 | spin_unlock_irqrestore(&port->lock, flags); |
214 | dbg("%s - already writing", __FUNCTION__); | 215 | dbg("%s - already writing", __FUNCTION__); |
215 | return 0; | 216 | return 0; |
216 | } | 217 | } |
217 | port->write_urb_busy = 1; | 218 | port->write_urb_busy = 1; |
218 | spin_unlock_bh(&port->lock); | 219 | spin_unlock_irqrestore(&port->lock, flags); |
219 | 220 | ||
220 | count = (count > port->bulk_out_size) ? port->bulk_out_size : count; | 221 | count = (count > port->bulk_out_size) ? port->bulk_out_size : count; |
221 | 222 | ||