From: Greg KH <gregkh@linuxfoundation.org>
To: Yi Yang <yiyang13@huawei.com>
Cc: pawell@cadence.com, linux-usb@vger.kernel.org, wangweiyang2@huawei.com
Subject: Re: [PATCH] usb: cdns2: fix possible null-ptr-deref in cdns2_gadget_ep_queue()
Date: Tue, 29 Oct 2024 04:36:55 +0100 [thread overview]
Message-ID: <2024102943-such-dismantle-0946@gregkh> (raw)
In-Reply-To: <20241028035028.2657102-1-yiyang13@huawei.com>
On Mon, Oct 28, 2024 at 03:50:28AM +0000, Yi Yang wrote:
> The cdns2_gadget_ep_alloc_request() will return NULL when kzalloc() fails,
> fix possible null-ptr-deref by check return value.
>
> Fixes: 3eb1f1efe204 ("usb: cdns2: Add main part of Cadence USBHS driver")
> Signed-off-by: Yi Yang <yiyang13@huawei.com>
> ---
> drivers/usb/gadget/udc/cdns2/cdns2-gadget.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/usb/gadget/udc/cdns2/cdns2-gadget.c b/drivers/usb/gadget/udc/cdns2/cdns2-gadget.c
> index 62fce42ef2da..c06a50af268e 100644
> --- a/drivers/usb/gadget/udc/cdns2/cdns2-gadget.c
> +++ b/drivers/usb/gadget/udc/cdns2/cdns2-gadget.c
> @@ -1724,6 +1724,10 @@ 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) {
> + spin_unlock_irqrestore(&pdev->lock, flags);
> + return -ENOMEM;
> + }
> zlp_request->buf = pdev->zlp_buf;
> zlp_request->length = 0;
>
> --
> 2.25.1
>
>
How was this tested to verify it works properly?
thanks,
greg k-h
prev parent reply other threads:[~2024-10-29 3:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-28 3:50 [PATCH] usb: cdns2: fix possible null-ptr-deref in cdns2_gadget_ep_queue() Yi Yang
2024-10-29 3:36 ` Greg KH [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2024102943-such-dismantle-0946@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
--cc=pawell@cadence.com \
--cc=wangweiyang2@huawei.com \
--cc=yiyang13@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox