usb: dwc3: gadget: early giveback if End Transfer already completed
authorFelipe Balbi <felipe.balbi@linux.intel.com>
Mon, 21 Jan 2019 11:01:16 +0000 (13:01 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 6 Nov 2019 12:05:31 +0000 (13:05 +0100)
commitd0e8b35e915e4d5bcd0368b846c9b84090fea2f6
treee222f7824b999df377483398d5af7f4ec09753f2
parent335d4f8182461f650ae5b931084d4134579674c9
usb: dwc3: gadget: early giveback if End Transfer already completed

[ Upstream commit 9f45581f5eec6786c6eded2b3c85345d82a910c9 ]

There is a rare race condition that may happen during a Disconnect
Interrupt if we have a started request that happens to be
dequeued *after* completion of End Transfer command. If that happens,
that request will be left waiting for completion of an End Transfer
command that will never happen.

If End Transfer command has already completed before, we are safe to
giveback the request straight away.

Tested-by: Thinh Nguyen <thinhn@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/usb/dwc3/gadget.c