From: Greg KH <gregkh@linuxfoundation.org>
To: Henry Martin <bsdhenrymartin@gmail.com>
Cc: joel@jms.id.au, andrew@codeconstruct.com.au,
linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-aspeed@lists.ozlabs.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH v2] usb/gadget: Add NULL check in ast_vhub_init_dev()
Date: Fri, 11 Apr 2025 15:06:34 +0200 [thread overview]
Message-ID: <2025041119-debit-cosmic-f41c@gregkh> (raw)
In-Reply-To: <20250405113020.80387-1-bsdhenrymartin@gmail.com>
On Sat, Apr 05, 2025 at 07:30:20PM +0800, Henry Martin wrote:
> devm_kasprintf() returns NULL when memory allocation fails. Currently,
> ast_vhub_init_dev() does not check for this case, which results in a
> NULL pointer dereference.
>
> Add NULL check after devm_kasprintf() to prevent this issue.
>
> Cc: stable@vger.kernel.org # v4.18
> Fixes: 7ecca2a4080c ("usb/gadget: Add driver for Aspeed SoC virtual hub")
> Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com>
> ---
> V1 -> V2: Add Cc: stable label and correct commit message.
>
> drivers/usb/gadget/udc/aspeed-vhub/dev.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/usb/gadget/udc/aspeed-vhub/dev.c b/drivers/usb/gadget/udc/aspeed-vhub/dev.c
> index 573109ca5b79..5b7d41a990d7 100644
> --- a/drivers/usb/gadget/udc/aspeed-vhub/dev.c
> +++ b/drivers/usb/gadget/udc/aspeed-vhub/dev.c
> @@ -548,6 +548,8 @@ int ast_vhub_init_dev(struct ast_vhub *vhub, unsigned int idx)
> d->vhub = vhub;
> d->index = idx;
> d->name = devm_kasprintf(parent, GFP_KERNEL, "port%d", idx+1);
> + if (!d->name)
> + return -ENOMEM;
> d->regs = vhub->regs + 0x100 + 0x10 * idx;
>
> ast_vhub_init_ep0(vhub, &d->ep0, d);
> --
> 2.34.1
>
What kernel version did you make this against? It does not apply to
6.15-rc1 for me :(
thanks,
greg k-h
next prev parent reply other threads:[~2025-04-11 13:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-05 11:30 [PATCH v2] usb/gadget: Add NULL check in ast_vhub_init_dev() Henry Martin
2025-04-11 13:06 ` Greg KH [this message]
2025-04-11 13:22 ` henry martin
2025-04-11 13:30 ` henry martin
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=2025041119-debit-cosmic-f41c@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=andrew@codeconstruct.com.au \
--cc=bsdhenrymartin@gmail.com \
--cc=joel@jms.id.au \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-aspeed@lists.ozlabs.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=stable@vger.kernel.org \
/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