* [PATCH v2] usb/gadget: Add NULL check in ast_vhub_init_dev()
@ 2025-04-05 11:30 Henry Martin
2025-04-11 13:06 ` Greg KH
0 siblings, 1 reply; 4+ messages in thread
From: Henry Martin @ 2025-04-05 11:30 UTC (permalink / raw)
To: gregkh, joel, andrew
Cc: linux-usb, linux-arm-kernel, linux-aspeed, linux-kernel,
Henry Martin, stable
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
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH v2] usb/gadget: Add NULL check in ast_vhub_init_dev()
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
2025-04-11 13:22 ` henry martin
2025-04-11 13:30 ` henry martin
0 siblings, 2 replies; 4+ messages in thread
From: Greg KH @ 2025-04-11 13:06 UTC (permalink / raw)
To: Henry Martin
Cc: joel, andrew, linux-usb, linux-arm-kernel, linux-aspeed,
linux-kernel, stable
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
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v2] usb/gadget: Add NULL check in ast_vhub_init_dev()
2025-04-11 13:06 ` Greg KH
@ 2025-04-11 13:22 ` henry martin
2025-04-11 13:30 ` henry martin
1 sibling, 0 replies; 4+ messages in thread
From: henry martin @ 2025-04-11 13:22 UTC (permalink / raw)
To: Greg KH
Cc: joel, andrew, linux-usb, linux-arm-kernel, linux-aspeed,
linux-kernel, stable
Hi Greg,
Thanks for the review.
This patch was made against v6.14. I’ll rebase it onto v6.15-rc1 and send a v3
shortly.
Best regards,
Henry
Greg KH <gregkh@linuxfoundation.org> 于2025年4月11日周五 21:06写道:
>
> 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
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v2] usb/gadget: Add NULL check in ast_vhub_init_dev()
2025-04-11 13:06 ` Greg KH
2025-04-11 13:22 ` henry martin
@ 2025-04-11 13:30 ` henry martin
1 sibling, 0 replies; 4+ messages in thread
From: henry martin @ 2025-04-11 13:30 UTC (permalink / raw)
To: Greg KH
Cc: joel, andrew, linux-usb, linux-arm-kernel, linux-aspeed,
linux-kernel, stable
> What kernel version did you make this against? It does not apply to
> 6.15-rc1 for me :(
Apologies for the noise.
I just rebased onto v6.15-rc1 and noticed that this issue has already been
fixed upstream.
Thanks again for taking the time to review — I'll drop this patch.
Best regards,
Henry
Greg KH <gregkh@linuxfoundation.org> 于2025年4月11日周五 21:06写道:
>
> 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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-04-12 4:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2025-04-11 13:22 ` henry martin
2025-04-11 13:30 ` henry martin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox