* [PATCH] usb: cdns2: fix a null pointer dereference in cdns2_gadget_ep_queue()
@ 2025-12-24 9:38 Haoxiang Li
2025-12-24 9:45 ` Greg KH
0 siblings, 1 reply; 2+ messages in thread
From: Haoxiang Li @ 2025-12-24 9:38 UTC (permalink / raw)
To: pawell, gregkh; +Cc: linux-usb, linux-kernel, Haoxiang Li, stable
If cdns2_gadget_ep_alloc_request() fails, a null pointer dereference
occurs. Add a check to prevent it.
Fixes: 3eb1f1efe204 ("usb: cdns2: Add main part of Cadence USBHS driver")
Cc: stable@vger.kernel.org
Signed-off-by: Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
---
drivers/usb/gadget/udc/cdns2/cdns2-gadget.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/usb/gadget/udc/cdns2/cdns2-gadget.c b/drivers/usb/gadget/udc/cdns2/cdns2-gadget.c
index 9b53daf76583..c5b9dae743d8 100644
--- a/drivers/usb/gadget/udc/cdns2/cdns2-gadget.c
+++ b/drivers/usb/gadget/udc/cdns2/cdns2-gadget.c
@@ -1725,6 +1725,8 @@ static int cdns2_gadget_ep_queue(struct usb_ep *ep, struct usb_request *request,
struct cdns2_request *preq;
zlp_request = cdns2_gadget_ep_alloc_request(ep, GFP_ATOMIC);
+ if (!zlp_request)
+ return -ENOMEM;
zlp_request->buf = pdev->zlp_buf;
zlp_request->length = 0;
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] usb: cdns2: fix a null pointer dereference in cdns2_gadget_ep_queue()
2025-12-24 9:38 [PATCH] usb: cdns2: fix a null pointer dereference in cdns2_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: pawell, linux-usb, linux-kernel, stable
On Wed, Dec 24, 2025 at 05:38:45PM +0800, Haoxiang Li wrote:
> If cdns2_gadget_ep_alloc_request() fails, a null pointer dereference
> occurs. Add a check to prevent it.
>
> Fixes: 3eb1f1efe204 ("usb: cdns2: Add main part of Cadence USBHS driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
> ---
> drivers/usb/gadget/udc/cdns2/cdns2-gadget.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/usb/gadget/udc/cdns2/cdns2-gadget.c b/drivers/usb/gadget/udc/cdns2/cdns2-gadget.c
> index 9b53daf76583..c5b9dae743d8 100644
> --- a/drivers/usb/gadget/udc/cdns2/cdns2-gadget.c
> +++ b/drivers/usb/gadget/udc/cdns2/cdns2-gadget.c
> @@ -1725,6 +1725,8 @@ static int cdns2_gadget_ep_queue(struct usb_ep *ep, struct usb_request *request,
> struct cdns2_request *preq;
>
> zlp_request = cdns2_gadget_ep_alloc_request(ep, GFP_ATOMIC);
> + if (!zlp_request)
> + return -ENOMEM;
As stated before, you need to document the tool that you use to find
these types of things.
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:38 [PATCH] usb: cdns2: fix a null pointer dereference in cdns2_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