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

net: usb: kaweth: 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.

Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Sebastian Andrzej Siewior and committed by
David S. Miller
ba49fed8 12c4de4b

+4 -4
+4 -4
drivers/net/usb/kaweth.c
··· 587 587 struct kaweth_device *kaweth = urb->context; 588 588 struct net_device *net = kaweth->net; 589 589 int status = urb->status; 590 - 590 + unsigned long flags; 591 591 int count = urb->actual_length; 592 592 int count2 = urb->transfer_buffer_length; 593 593 ··· 619 619 net->stats.rx_errors++; 620 620 dev_dbg(dev, "Status was -EOVERFLOW.\n"); 621 621 } 622 - spin_lock(&kaweth->device_lock); 622 + spin_lock_irqsave(&kaweth->device_lock, flags); 623 623 if (IS_BLOCKED(kaweth->status)) { 624 - spin_unlock(&kaweth->device_lock); 624 + spin_unlock_irqrestore(&kaweth->device_lock, flags); 625 625 return; 626 626 } 627 - spin_unlock(&kaweth->device_lock); 627 + spin_unlock_irqrestore(&kaweth->device_lock, flags); 628 628 629 629 if(status && status != -EREMOTEIO && count != 1) { 630 630 dev_err(&kaweth->intf->dev,