2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-17 17:53:56 +08:00

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>
This commit is contained in:
Johan Hovold 2010-03-17 23:00:43 +01:00 committed by Greg Kroah-Hartman
parent 30af7fb5a4
commit 50dbb85287

View File

@ -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)