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

USB: serial: symbolserial: 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
5e02bfcf d4bf25b3

+3 -2
+3 -2
drivers/usb/serial/symbolserial.c
··· 35 35 struct symbol_private *priv = usb_get_serial_port_data(port); 36 36 unsigned char *data = urb->transfer_buffer; 37 37 int status = urb->status; 38 + unsigned long flags; 38 39 int result; 39 40 int data_length; 40 41 ··· 74 73 } 75 74 76 75 exit: 77 - spin_lock(&priv->lock); 76 + spin_lock_irqsave(&priv->lock, flags); 78 77 79 78 /* Continue trying to always read if we should */ 80 79 if (!priv->throttled) { ··· 85 84 __func__, result); 86 85 } else 87 86 priv->actually_throttled = true; 88 - spin_unlock(&priv->lock); 87 + spin_unlock_irqrestore(&priv->lock, flags); 89 88 } 90 89 91 90 static int symbol_open(struct tty_struct *tty, struct usb_serial_port *port)