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

USB: serial: sierra: 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: John Ogness <john.ogness@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Johan Hovold <johan@kernel.org>

authored by

John Ogness and committed by
Johan Hovold
d4bf25b3 e6087001

+5 -4
+5 -4
drivers/usb/serial/sierra.c
··· 409 409 struct sierra_port_private *portdata = usb_get_serial_port_data(port); 410 410 struct sierra_intf_private *intfdata; 411 411 int status = urb->status; 412 + unsigned long flags; 412 413 413 414 intfdata = usb_get_serial_data(port->serial); 414 415 ··· 420 419 dev_dbg(&port->dev, "%s - nonzero write bulk status " 421 420 "received: %d\n", __func__, status); 422 421 423 - spin_lock(&portdata->lock); 422 + spin_lock_irqsave(&portdata->lock, flags); 424 423 --portdata->outstanding_urbs; 425 - spin_unlock(&portdata->lock); 426 - spin_lock(&intfdata->susp_lock); 424 + spin_unlock_irqrestore(&portdata->lock, flags); 425 + spin_lock_irqsave(&intfdata->susp_lock, flags); 427 426 --intfdata->in_flight; 428 - spin_unlock(&intfdata->susp_lock); 427 + spin_unlock_irqrestore(&intfdata->susp_lock, flags); 429 428 430 429 usb_serial_port_softint(port); 431 430 }