Linux USB
 help / color / mirror / Atom feed
* [PATCH] usb: cdns3: Handle ZLP request allocation failure
@ 2026-08-17  7:59 Triet Hoang
  2026-08-17  9:03 ` [PATCH v2] " Triet Hoang
  0 siblings, 1 reply; 3+ messages in thread
From: Triet Hoang @ 2026-08-17  7:59 UTC (permalink / raw)
  To: peter.chen; +Cc: pawell, rogerq, gregkh, linux-usb, linux-kernel, Triet Hoang

Check the return value of cdns3_gadget_ep_alloc_request() before
dereferencing the returned request.

Signed-off-by: Triet Hoang <triet.hoang.dev@gmail.com>
---
 drivers/usb/cdns3/cdns3-gadget.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/usb/cdns3/cdns3-gadget.c b/drivers/usb/cdns3/cdns3-gadget.c
index 42311c1bfada..6211e1f2c0c1 100644
--- a/drivers/usb/cdns3/cdns3-gadget.c
+++ b/drivers/usb/cdns3/cdns3-gadget.c
@@ -2662,6 +2662,11 @@ 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) {
+			ret = -ENOMEM;
+			goto out;
+		}
+
 		zlp_request->buf = priv_dev->zlp_buf;
 		zlp_request->length = 0;
 
@@ -2673,6 +2678,7 @@ static int cdns3_gadget_ep_queue(struct usb_ep *ep, struct usb_request *request,
 		ret = __cdns3_gadget_ep_queue(ep, zlp_request, gfp_flags);
 	}
 
+out:
 	spin_unlock_irqrestore(&priv_dev->lock, flags);
 	return ret;
 }
-- 
2.53.0


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

end of thread, other threads:[~2026-08-17 11:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-17  7:59 [PATCH] usb: cdns3: Handle ZLP request allocation failure Triet Hoang
2026-08-17  9:03 ` [PATCH v2] " Triet Hoang
2026-08-17 11:01   ` Greg KH

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