usbserial: fix inconsistent lock state
authorBorislav Petkov <bbpetkov@yahoo.de>
Sun, 28 Oct 2007 12:24:16 +0000 (13:24 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 28 Nov 2007 21:58:34 +0000 (13:58 -0800)
In commit acd2a847e7fee7df11817f67dba75a2802793e5d 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>
drivers/usb/serial/generic.c

index 9eb4a65ee4d9943026f74de49c4e3013c8f3f65f..d41531139c55e249ce14cd0ca86ada8cd5024409 100644 (file)
@@ -327,6 +327,7 @@ void usb_serial_generic_read_bulk_callback (struct urb *urb)
        struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
        unsigned char *data = urb->transfer_buffer;
        int status = urb->status;
+       unsigned long flags;
 
        dbg("%s - port %d", __FUNCTION__, port->number);
 
@@ -339,11 +340,11 @@ void usb_serial_generic_read_bulk_callback (struct urb *urb)
        usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data);
 
        /* Throttle the device if requested by tty */
-       spin_lock(&port->lock);
+       spin_lock_irqsave(&port->lock, flags);
        if (!(port->throttled = port->throttle_req))
                /* Handle data and continue reading from device */
                flush_and_resubmit_read_urb(port);
-       spin_unlock(&port->lock);
+       spin_unlock_irqrestore(&port->lock, flags);
 }
 EXPORT_SYMBOL_GPL(usb_serial_generic_read_bulk_callback);