Skip to contentSkip to conversation

usbip: vhci_hcd: fix calling usb_hcd_giveback_urb() with irqs enabled

PATCH In review Shuah Khan 2 participants 2 messages Oct 6, 2020

Subsystems (2)
lore
Share & tools
lore

Shuah Khan

author maintainer
#0 lore raw

PATCH v2 1/1 usbip: vhci_hcd: fix calling usb_hcd_giveback_urb() with irqs enabled

kcov testing uncovered call to usb_hcd_giveback_urb() without disabling interrupts.

usb_hcd_giveback_urb() is called from vhci's urb_enqueue, when it determines it doesn't need to xmit the urb and can give it back. This path runs in task context.

Disable irqs around usb_hcd_giveback_urb() call.

---

Changes in v2: Changelog updated with correct information.

 drivers/usb/usbip/vhci_hcd.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/usb/usbip/vhci_hcd.c +7 -1
index 1b598db5d8b9..66cde5e5f796 100644
@@ -797,8 +797,14 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag
 	usb_hcd_unlink_urb_from_ep(hcd, urb);
 no_need_unlink:
 	spin_unlock_irqrestore(&vhci->lock, flags);
-	if (!ret)
+	if (!ret) {
+		/* usb_hcd_giveback_urb() should be called with
+		 * irqs disabled
+		 */
+		local_irq_disable();
 		usb_hcd_giveback_urb(hcd, urb, urb->status);
+		local_irq_enable();
+	}
 	return ret;
 }
 
Signature · 1 line
2.25.1
Acked-by on v2 1/1
#1 lore raw
Quoted 10 lines · Shuah Khan

kcov testing uncovered call to usb_hcd_giveback_urb() without disabling interrupts.

usb_hcd_giveback_urb() is called from vhci's urb_enqueue, when it determines it doesn't need to xmit the urb and can give it back. This path runs in task context.

Quoted 5 lines

Disable irqs around usb_hcd_giveback_urb() call.

Thank you!

Quoted 29 lines

---

Changes in v2: Changelog updated with correct information.

 drivers/usb/usbip/vhci_hcd.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/usb/usbip/vhci_hcd.c +7 -2
index 1b598db5d8b9..66cde5e5f796 100644
@@ -797,8 +797,14 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag
        usb_hcd_unlink_urb_from_ep(hcd, urb);
 no_need_unlink:
        spin_unlock_irqrestore(&vhci->lock, flags);
-       if (!ret)
+       if (!ret) {
+               /* usb_hcd_giveback_urb() should be called with
+                * irqs disabled
+                */
+               local_irq_disable();
                usb_hcd_giveback_urb(hcd, urb, urb->status);
+               local_irq_enable();
+       }
        return ret;
 }
 
--

2.25.1