linux/drivers/usb/dwc3
Felipe Balbi c91815b596 usb: dwc3: gadget: never call ->complete() from ->ep_queue()
This is a requirement which has always existed but, somehow, wasn't
reflected in the documentation and problems weren't found until now
when Tuba Yavuz found a possible deadlock happening between dwc3 and
f_hid. She described the situation as follows:

spin_lock_irqsave(&hidg->write_spinlock, flags); // first acquire
/* we our function has been disabled by host */
if (!hidg->req) {
	free_ep_req(hidg->in_ep, hidg->req);
	goto try_again;
}

[...]

status = usb_ep_queue(hidg->in_ep, hidg->req, GFP_ATOMIC);
=>
	[...]
	=> usb_gadget_giveback_request
		=>
		f_hidg_req_complete
			=>
			spin_lock_irqsave(&hidg->write_spinlock, flags); // second acquire

Note that this happens because dwc3 would call ->complete() on a
failed usb_ep_queue() due to failed Start Transfer command. This is,
anyway, a theoretical situation because dwc3 currently uses "No
Response Update Transfer" command for Bulk and Interrupt endpoints.

It's still good to make this case impossible to happen even if the "No
Reponse Update Transfer" command is changed.

Reported-by: Tuba Yavuz <tuba@ece.ufl.edu>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-03-26 13:22:09 +02:00
..
Kconfig usb: changes for v4.12 2017-04-11 16:47:26 +02:00
Makefile usb: dwc3: Makefile: fix link error on randconfig 2018-03-22 10:45:20 +02:00
core.c usb: changes for v4.17 merge window 2018-03-23 13:33:09 +01:00
core.h usb: dwc3: Dump LSP and BMU debug info 2018-03-22 10:49:02 +02:00
debug.h usb: dwc3: debug: decode a few more features 2017-12-11 12:36:48 +02:00
debugfs.c usb: dwc3: Dump LSP and BMU debug info 2018-03-22 10:49:02 +02:00
drd.c usb: dwc3: add dual role support using OTG block 2018-03-13 10:47:52 +02:00
dwc3-exynos.c USB: dwc3: Remove redundant license text 2017-11-07 15:45:01 +01:00
dwc3-keystone.c USB: dwc3: Remove redundant license text 2017-11-07 15:45:01 +01:00
dwc3-of-simple.c usb: dwc3: of-simple: add support for the Amlogic Meson GXL and AXG SoCs 2018-03-13 10:47:50 +02:00
dwc3-omap.c usb: dwc3: omap: don't miss events during suspend/resume 2018-02-12 10:53:18 +02:00
dwc3-pci.c usb: dwc3: pci: Properly cleanup resource 2018-03-22 10:48:18 +02:00
dwc3-st.c USB: dwc3: Remove redundant license text 2017-11-07 15:45:01 +01:00
ep0.c usb: dwc3: ep0: remove redundant assignment 2018-03-19 10:52:12 +02:00
gadget.c usb: dwc3: gadget: never call ->complete() from ->ep_queue() 2018-03-26 13:22:09 +02:00
gadget.h USB: dwc3: Remove redundant license text 2017-11-07 15:45:01 +01:00
host.c USB: dwc3: Remove redundant license text 2017-11-07 15:45:01 +01:00
io.h USB: dwc3: Remove redundant license text 2017-11-07 15:45:01 +01:00
trace.c USB: dwc3: Remove redundant license text 2017-11-07 15:45:01 +01:00
trace.h usb: dwc3: Make sparse a bit happier 2017-12-11 12:36:49 +02:00
ulpi.c USB: dwc3: Remove redundant license text 2017-11-07 15:45:01 +01:00