From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Henry Martin <bsdhenrymartin@gmail.com>,
linux-usb@vger.kernel.org, linux-aspeed@lists.ozlabs.org
Cc: gregkh@linuxfoundation.org, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] Subject: [PATCH] usb: gadget: aspeed: Add NULL check in the ast_vhub_init_dev
Date: Tue, 01 Apr 2025 14:47:57 +1100 [thread overview]
Message-ID: <bcce62d1bb233edaf39637a60089fcc146c8173f.camel@kernel.crashing.org> (raw)
In-Reply-To: <20250329002911.132826-1-bsdhenrymartin@gmail.com>
On Sat, 2025-03-29 at 08:29 +0800, Henry Martin wrote:
> When devm_kasprintf() fails, it returns a NULL pointer. However, this
> return value is not properly checked in the function
> ast_vhub_init_dev.
>
> A NULL check should be added after the devm_kasprintf call to prevent
> potential NULL pointer dereference error.
>
> Fixes: 7ecca2a4080cb ("usb/gadget: Add driver for Aspeed SoC virtual
> hub")
> Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> ---
> drivers/usb/gadget/udc/aspeed-vhub/dev.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/gadget/udc/aspeed-vhub/dev.c
> b/drivers/usb/gadget/udc/aspeed-vhub/dev.c
> index 573109ca5b79..1709a58299a5 100644
> --- a/drivers/usb/gadget/udc/aspeed-vhub/dev.c
> +++ b/drivers/usb/gadget/udc/aspeed-vhub/dev.c
> @@ -545,9 +545,11 @@ int ast_vhub_init_dev(struct ast_vhub *vhub,
> unsigned int idx)
> struct device *parent = &vhub->pdev->dev;
> int rc;
>
> + d->name = devm_kasprintf(parent, GFP_KERNEL, "port%d", idx +
> 1);
> + if (!d->name)
> + return -ENOMEM;
> d->vhub = vhub;
> d->index = idx;
> - d->name = devm_kasprintf(parent, GFP_KERNEL, "port%d",
> idx+1);
> d->regs = vhub->regs + 0x100 + 0x10 * idx;
>
> ast_vhub_init_ep0(vhub, &d->ep0, d);
next prev parent reply other threads:[~2025-04-01 3:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-29 0:29 [PATCH] Subject: [PATCH] usb: gadget: aspeed: Add NULL check in the ast_vhub_init_dev Henry Martin
2025-04-01 3:47 ` Benjamin Herrenschmidt [this message]
2025-04-05 11:07 ` Greg KH
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=bcce62d1bb233edaf39637a60089fcc146c8173f.camel@kernel.crashing.org \
--to=benh@kernel.crashing.org \
--cc=bsdhenrymartin@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-aspeed@lists.ozlabs.org \
--cc=linux-usb@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;
as well as URLs for NNTP newsgroup(s).