Make reservation of write URB atomic. Signed-off-by: <dvomlehn@xxxxxxxxx> --- drivers/usb/serial/generic.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c index a817ced..7085809 100644 --- a/drivers/usb/serial/generic.c +++ b/drivers/usb/serial/generic.c @@ -199,6 +199,9 @@ retry: } i = (int)find_first_bit(&port->write_urbs_free, ARRAY_SIZE(port->write_urbs)); + if (i == ARRAY_SIZE(port->write_urbs)) + return 0; + clear_bit(i, &port->write_urbs_free); spin_unlock_irqrestore(&port->lock, flags); urb = port->write_urbs[i]; @@ -213,9 +216,9 @@ retry: dev_err(&port->dev, "%s - error submitting urb: %d\n", __func__, result); clear_bit_unlock(USB_SERIAL_WRITE_BUSY, &port->flags); + set_bit(i, &port->write_urbs_free); return result; } - clear_bit(i, &port->write_urbs_free); spin_lock_irqsave(&port->lock, flags); port->tx_bytes += count; -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html