* [PATCH 5.10] usb: cdns3: gadget: fix NULL pointer dereference in ep_queue
@ 2026-07-02 10:20 Mikhail Dmitrichenko
2026-07-03 4:07 ` Sasha Levin
0 siblings, 1 reply; 2+ messages in thread
From: Mikhail Dmitrichenko @ 2026-07-02 10:20 UTC (permalink / raw)
To: stable, Greg Kroah-Hartman
Cc: Mikhail Dmitrichenko, Peter Chen, Pawel Laszczak, Roger Quadros,
Felipe Balbi, linux-usb, linux-kernel, Peter Chen, Roger Quadros,
lvc-project, stable, Yongchao Wu
From: Yongchao Wu <yongchao.wu@autochips.com>
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>
Signed-off-by: Mikhail Dmitrichenko <mdmitrichenko@astralinux.ru>
---
Backport fix for CVE-2026-31755
drivers/usb/cdns3/gadget.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c
index 61388e2089f5f..a64302acdfe6d 100644
--- a/drivers/usb/cdns3/gadget.c
+++ b/drivers/usb/cdns3/gadget.c
@@ -2587,6 +2587,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);
--
2.47.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 5.10] usb: cdns3: gadget: fix NULL pointer dereference in ep_queue
2026-07-02 10:20 [PATCH 5.10] usb: cdns3: gadget: fix NULL pointer dereference in ep_queue Mikhail Dmitrichenko
@ 2026-07-03 4:07 ` Sasha Levin
0 siblings, 0 replies; 2+ messages in thread
From: Sasha Levin @ 2026-07-03 4:07 UTC (permalink / raw)
To: stable, Greg Kroah-Hartman
Cc: Sasha Levin, Mikhail Dmitrichenko, Peter Chen, Pawel Laszczak,
Roger Quadros, Felipe Balbi, linux-usb, linux-kernel, Peter Chen,
Roger Quadros, lvc-project, stable, Yongchao Wu
On Thu, Jul 02, 2026 at 01:20:17PM +0300, Mikhail Dmitrichenko wrote:
> From: Yongchao Wu <yongchao.wu@autochips.com>
>
> 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.
Queued up for 5.10.y, thanks!
--
Thanks,
Sasha
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-03 4:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-02 10:20 [PATCH 5.10] usb: cdns3: gadget: fix NULL pointer dereference in ep_queue Mikhail Dmitrichenko
2026-07-03 4:07 ` Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox