public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: cdns3: fix a null pointer dereference in cdns3_gadget_ep_queue()
@ 2025-12-24  9:29 Haoxiang Li
  2025-12-24  9:45 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Haoxiang Li @ 2025-12-24  9:29 UTC (permalink / raw)
  To: peter.chen, pawell, rogerq, gregkh, felipe.balbi
  Cc: linux-usb, linux-kernel, Haoxiang Li, stable

If cdns3_gadget_ep_alloc_request() fails, a null pointer dereference
occurs. Add a check to prevent it.

Found by code review and compiled on ubuntu 20.04.

Fixes: 7733f6c32e36 ("usb: cdns3: Add Cadence USB3 DRD Driver")
Cc: stable@vger.kernel.org
Signed-off-by: Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
---
 drivers/usb/cdns3/cdns3-gadget.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/cdns3/cdns3-gadget.c b/drivers/usb/cdns3/cdns3-gadget.c
index 168707213ed9..cc2421a34588 100644
--- a/drivers/usb/cdns3/cdns3-gadget.c
+++ b/drivers/usb/cdns3/cdns3-gadget.c
@@ -2659,6 +2659,8 @@ static int cdns3_gadget_ep_queue(struct usb_ep *ep, struct usb_request *request,
 		struct cdns3_request *priv_req;
 
 		zlp_request = cdns3_gadget_ep_alloc_request(ep, GFP_ATOMIC);
+		if (!zlp_request)
+			return -ENOMEM;
 		zlp_request->buf = priv_dev->zlp_buf;
 		zlp_request->length = 0;
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] usb: cdns3: fix a null pointer dereference in cdns3_gadget_ep_queue()
  2025-12-24  9:29 [PATCH] usb: cdns3: fix a null pointer dereference in cdns3_gadget_ep_queue() Haoxiang Li
@ 2025-12-24  9:45 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2025-12-24  9:45 UTC (permalink / raw)
  To: Haoxiang Li
  Cc: peter.chen, pawell, rogerq, felipe.balbi, linux-usb, linux-kernel,
	stable

On Wed, Dec 24, 2025 at 05:29:35PM +0800, Haoxiang Li wrote:
> If cdns3_gadget_ep_alloc_request() fails, a null pointer dereference
> occurs. Add a check to prevent it.
> 
> Found by code review and compiled on ubuntu 20.04.

What tool did you use to find this through 'code review'?

And the compile line doesn't help, as I stated before.

And how was this tested?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-12-24  9:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-24  9:29 [PATCH] usb: cdns3: fix a null pointer dereference in cdns3_gadget_ep_queue() Haoxiang Li
2025-12-24  9:45 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox