summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYongchao Wu <yongchao.wu@autochips.com>2026-03-31 08:04:07 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-04-11 14:29:50 +0200
commit14bf08ab2cdfcdfd3f13e799d06692a1b3e0745f (patch)
tree3233e7b46f9c28f729f70a6eb9f431dcc1e04012
parent04d8e0411c21c765b5fc630bad3fad18ad17b271 (diff)
usb: cdns3: gadget: fix NULL pointer dereference in ep_queue
commit 7f6f127b9bc34bed35f56faf7ecb1561d6b39000 upstream. When the gadget endpoint is disabled or not yet configured, the ep->desc pointer can be NULL. This leads to a NULL pointer dereference when __cdns3_gadget_ep_queue() is called, causing a kernel crash. Add a check to return -ESHUTDOWN if ep->desc is NULL, which is the standard return code for unconfigured endpoints. This prevents potential crashes when ep_queue is called on endpoints that are not ready. Fixes: 7733f6c32e36 ("usb: cdns3: Add Cadence USB3 DRD Driver") Cc: stable <stable@kernel.org> Signed-off-by: Yongchao Wu <yongchao.wu@autochips.com> Acked-by: Peter Chen <peter.chen@kernel.org> Link: https://patch.msgid.link/20260331000407.613298-1-yongchao.wu@autochips.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/usb/cdns3/cdns3-gadget.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/usb/cdns3/cdns3-gadget.c b/drivers/usb/cdns3/cdns3-gadget.c
index 168707213ed9..7503fc340c5b 100644
--- a/drivers/usb/cdns3/cdns3-gadget.c
+++ b/drivers/usb/cdns3/cdns3-gadget.c
@@ -2589,6 +2589,9 @@ static int __cdns3_gadget_ep_queue(struct usb_ep *ep,
struct cdns3_request *priv_req;
int ret = 0;
+ if (!ep->desc)
+ return -ESHUTDOWN;
+
request->actual = 0;
request->status = -EINPROGRESS;
priv_req = to_cdns3_request(request);