Skip to content

Commit

Permalink
USB: serial: fix missing locking on fifo in write callback
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Johan Hovold authored and Greg Kroah-Hartman committed May 20, 2010
1 parent 30af7fb commit 50dbb85
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions drivers/usb/serial/generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -519,10 +519,13 @@ void usb_serial_generic_write_bulk_callback(struct urb *urb)
port->write_urb_busy = 0;
spin_unlock_irqrestore(&port->lock, flags);

if (status)
if (status) {
spin_lock_irqsave(&port->lock, flags);
kfifo_reset_out(&port->write_fifo);
else
spin_unlock_irqrestore(&port->lock, flags);
} else {
usb_serial_generic_write_start(port);
}
}

if (status)
Expand Down

0 comments on commit 50dbb85

Please sign in to comment.