usb: dwc3: gadget: Fix null pointer exception
authorAlbert Wang <albertccwang@google.com>
Tue, 9 Nov 2021 09:26:42 +0000 (17:26 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Nov 2021 14:02:52 +0000 (15:02 +0100)
commit26288448120b28af1dfd85a6fa6b6d55a16c7f2f
tree00e7f6ffda29077082a134f781ed050b8783d2aa
parent3b8599a6f4817bdd7c5e7145f2972b7f22f00a9d
usb: dwc3: gadget: Fix null pointer exception

In the endpoint interrupt functions
dwc3_gadget_endpoint_transfer_in_progress() and
dwc3_gadget_endpoint_trbs_complete() will dereference the endpoint
descriptor. But it could be cleared in __dwc3_gadget_ep_disable()
when accessory disconnected. So we need to check whether it is null
or not before dereferencing it.

Fixes: f09ddcfcb8c5 ("usb: dwc3: gadget: Prevent EP queuing while stopping transfers")
Cc: stable <stable@vger.kernel.org>
Reviewed-by: Jack Pham <quic_jackp@quicinc.com>
Signed-off-by: Albert Wang <albertccwang@google.com>
Link: https://lore.kernel.org/r/20211109092642.3507692-1-albertccwang@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/dwc3/gadget.c