Skip to content

Commit

Permalink
usbip: vhci_hcd: fix calling usb_hcd_giveback_urb() with irqs enabled
Browse files Browse the repository at this point in the history
kcov testing uncovered call to usb_hcd_giveback_urb() without disabling
interrupts.

Link: https://lore.kernel.org/linux-usb/CAAeHK+wb4k-LGTjK9F5YbJNviF_+yU+wE_=Vpo9Rn7KFN8vG6Q@mail.gmail.com/

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.

Reported-by: Andrey Konovalov <andreyknvl@google.com>
Suggested-by: Alan Stern <stern@rowland.harvard.edu>
Acked-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Link: https://lore.kernel.org/r/20201006223914.39257-1-skhan@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Shuah Khan authored and Greg Kroah-Hartman committed Oct 7, 2020
1 parent a4f8843 commit 9e85868
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion drivers/usb/usbip/vhci_hcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 9e85868

Please sign in to comment.