Message ID | 20250405113020.80387-1-bsdhenrymartin@gmail.com |
---|---|
State | New |
Headers | show |
Series | [v2] usb/gadget: Add NULL check in ast_vhub_init_dev() | expand |
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);
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(+)