From: Greg KH <gregkh@linuxfoundation.org>
To: Chen Ridong <chenridong@huaweicloud.com>
Cc: peter.chen@kernel.org, pawell@cadence.com, rogerq@kernel.org,
linux-usb@vger.kernel.org, chenridong@huawei.com,
wangweiyang2@huawei.com
Subject: Re: [PATCH] usb: cdns3: avoid possible null_ptr_deref in cdns3_gadget_ep_queue
Date: Tue, 29 Oct 2024 04:35:46 +0100 [thread overview]
Message-ID: <2024102917-wand-shanty-bbbc@gregkh> (raw)
In-Reply-To: <20241025064331.1049538-1-chenridong@huaweicloud.com>
On Fri, Oct 25, 2024 at 06:43:31AM +0000, Chen Ridong wrote:
> From: Chen Ridong <chenridong@huawei.com>
>
> The cdns3_gadget_ep_alloc_request functions may return NULL
> when memory is out of use. To void possible null_ptr_deref,
> return ENOMEM when cdns3_gadget_ep_alloc_request returns NULL.
>
> Signed-off-by: Chen Ridong <chenridong@huawei.com>
> ---
> drivers/usb/cdns3/cdns3-gadget.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/usb/cdns3/cdns3-gadget.c b/drivers/usb/cdns3/cdns3-gadget.c
> index fd1beb10bba7..982e8e0759e8 100644
> --- a/drivers/usb/cdns3/cdns3-gadget.c
> +++ b/drivers/usb/cdns3/cdns3-gadget.c
> @@ -2657,6 +2657,10 @@ 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) {
> + spin_unlock_irqrestore(&priv_dev->lock, flags);
> + return -ENOMEM;
Are you sure this is ok? What about the resources that have been
allocated before this return would interrupt them? How was this tested?
thanks,
greg k-h
prev parent reply other threads:[~2024-10-29 3:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-25 6:43 [PATCH] usb: cdns3: avoid possible null_ptr_deref in cdns3_gadget_ep_queue Chen Ridong
2024-10-29 3:35 ` 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=2024102917-wand-shanty-bbbc@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=chenridong@huawei.com \
--cc=chenridong@huaweicloud.com \
--cc=linux-usb@vger.kernel.org \
--cc=pawell@cadence.com \
--cc=peter.chen@kernel.org \
--cc=rogerq@kernel.org \
--cc=wangweiyang2@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