aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorJohan Hovold <jhovold@gmail.com>2010-03-17 18:00:43 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2010-05-20 16:21:33 -0400
commit50dbb8528757b1977efd5d270ed9d262cbbef87d (patch)
treed64c9e367ba2aef9cd2325aa2304edd47fc39eff /drivers/usb
parent30af7fb5a40f8724c130428473edffa73170e04c (diff)
USB: serial: fix missing locking on fifo in write callback
On errors the fifo was reset without any locking. This could race with write which do kfifo_put and perhaps also chars_in_buffer and write_room. Every other access to the fifo is protected using the port lock so better add it to the error path as well. Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/serial/generic.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
index 8f78d7b8e888..2a3196a2c66c 100644
--- a/drivers/usb/serial/generic.c
+++ b/drivers/usb/serial/generic.c
@@ -519,10 +519,13 @@ void usb_serial_generic_write_bulk_callback(struct urb *urb)
519 port->write_urb_busy = 0; 519 port->write_urb_busy = 0;
520 spin_unlock_irqrestore(&port->lock, flags); 520 spin_unlock_irqrestore(&port->lock, flags);
521 521
522 if (status) 522 if (status) {
523 spin_lock_irqsave(&port->lock, flags);
523 kfifo_reset_out(&port->write_fifo); 524 kfifo_reset_out(&port->write_fifo);
524 else 525 spin_unlock_irqrestore(&port->lock, flags);
526 } else {
525 usb_serial_generic_write_start(port); 527 usb_serial_generic_write_start(port);
528 }
526 } 529 }
527 530
528 if (status) 531 if (status)