Skip to content

Commit bfaeafc

Browse files
Borislav Petkovgregkh
authored andcommitted
usbserial: fix inconsistent lock state
In commit acd2a84 usb_serial_generic_write() disables interrupts when taking &port->lock which is also taken in usb_serial_generic_read_bulk_callback() resulting in an inconsistent lock state due to the latter not disabling interrupts on the local cpu. Fix that by disabling interrupts in the latter call site also. Signed-off-by: Borislav Petkov <bbpetkov@yahoo.de> Acked-by: Jiri Kosina <jkosina@suse.cz> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
1 parent ed206ec commit bfaeafc

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎drivers/usb/serial/generic.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ void usb_serial_generic_read_bulk_callback (struct urb *urb)
327327
struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
328328
unsigned char *data = urb->transfer_buffer;
329329
int status = urb->status;
330+
unsigned long flags;
330331

331332
dbg("%s - port %d", __FUNCTION__, port->number);
332333

@@ -339,11 +340,11 @@ void usb_serial_generic_read_bulk_callback (struct urb *urb)
339340
usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data);
340341

341342
/* Throttle the device if requested by tty */
342-
spin_lock(&port->lock);
343+
spin_lock_irqsave(&port->lock, flags);
343344
if (!(port->throttled = port->throttle_req))
344345
/* Handle data and continue reading from device */
345346
flush_and_resubmit_read_urb(port);
346-
spin_unlock(&port->lock);
347+
spin_unlock_irqrestore(&port->lock, flags);
347348
}
348349
EXPORT_SYMBOL_GPL(usb_serial_generic_read_bulk_callback);
349350

0 commit comments

Comments
 (0)