Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: ldusb: use irqsave() in USB's complete callback

The USB completion callback does not disable interrupts while acquiring
the lock. We want to remove the local_irq_disable() invocation from
__usb_hcd_giveback_urb() and therefore it is required for the callback
handler to disable the interrupts while acquiring the lock.
The callback may be invoked either in IRQ or BH context depending on the
USB host controller.
Use the _irqsave() variant of the locking primitives.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Sebastian Andrzej Siewior and committed by
Greg Kroah-Hartman
d7cdbdd0 efd61e94

+4 -3
+4 -3
drivers/usb/misc/ldusb.c
··· 225 225 size_t *actual_buffer; 226 226 unsigned int next_ring_head; 227 227 int status = urb->status; 228 + unsigned long flags; 228 229 int retval; 229 230 230 231 if (status) { ··· 237 236 dev_dbg(&dev->intf->dev, 238 237 "%s: nonzero status received: %d\n", __func__, 239 238 status); 240 - spin_lock(&dev->rbsl); 239 + spin_lock_irqsave(&dev->rbsl, flags); 241 240 goto resubmit; /* maybe we can recover */ 242 241 } 243 242 } 244 243 245 - spin_lock(&dev->rbsl); 244 + spin_lock_irqsave(&dev->rbsl, flags); 246 245 if (urb->actual_length > 0) { 247 246 next_ring_head = (dev->ring_head+1) % ring_buffer_size; 248 247 if (next_ring_head != dev->ring_tail) { ··· 271 270 dev->buffer_overflow = 1; 272 271 } 273 272 } 274 - spin_unlock(&dev->rbsl); 273 + spin_unlock_irqrestore(&dev->rbsl, flags); 275 274 exit: 276 275 dev->interrupt_in_done = 1; 277 276 wake_up_interruptible(&dev->read_wait);