Skip to content

Commit

Permalink
USB: serial: fix race in generic write
Browse files Browse the repository at this point in the history
Fix race in generic write implementation, which could lead to
temporarily degraded throughput.

The current generic write implementation introduced by commit
27c7acf ("USB: serial: reimplement generic fifo-based writes") has
always had this bug, although it's fairly hard to trigger and the
consequences are not likely to be noticed.

Specifically, a write() on one CPU while the completion handler is
running on another could result in only one of the two write urbs being
utilised to empty the remainder of the write fifo (unless there is a
second write() that doesn't race during that time).

Cc: stable <stable@vger.kernel.org> # 2.6.35
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Johan Hovold authored and Greg Kroah-Hartman committed Nov 25, 2013
1 parent 6ce4eac commit 6f64854
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions drivers/usb/serial/generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,8 @@ int usb_serial_generic_write_start(struct usb_serial_port *port,
clear_bit_unlock(USB_SERIAL_WRITE_BUSY, &port->flags);
return result;
}
/*
* Try sending off another urb, unless called from completion handler
* (in which case there will be no free urb or no data).
*/
if (mem_flags != GFP_ATOMIC)
goto retry;

clear_bit_unlock(USB_SERIAL_WRITE_BUSY, &port->flags);

return 0;
goto retry; /* try sending off another urb */
}
EXPORT_SYMBOL_GPL(usb_serial_generic_write_start);

Expand Down

0 comments on commit 6f64854

Please sign in to comment.