Skip to content

Commit 8c75f3e

Browse files
WhiteFox-Projectgregkh
authored andcommitted
usb: gadget: aspeed: Add NULL pointer check in ast_vhub_init_dev()
The variable d->name, returned by devm_kasprintf(), could be NULL. A pointer check is added to prevent potential NULL pointer dereference. This is similar to the fix in commit 3027e7b ("ice: Fix some null pointer dereference issues in ice_ptp.c"). This issue is found by our static analysis tool Signed-off-by: Chenyuan Yang <chenyuan0y@gmail.com> Link: https://lore.kernel.org/r/20250311012705.1233829-1-chenyuan0y@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 440ca0c commit 8c75f3e

File tree

1 file changed

+3
-0
lines changed
  • drivers/usb/gadget/udc/aspeed-vhub

1 file changed

+3
-0
lines changed

drivers/usb/gadget/udc/aspeed-vhub/dev.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,9 @@ int ast_vhub_init_dev(struct ast_vhub *vhub, unsigned int idx)
548548
d->vhub = vhub;
549549
d->index = idx;
550550
d->name = devm_kasprintf(parent, GFP_KERNEL, "port%d", idx+1);
551+
if (!d->name)
552+
return -ENOMEM;
553+
551554
d->regs = vhub->regs + 0x100 + 0x10 * idx;
552555

553556
ast_vhub_init_ep0(vhub, &d->ep0, d);

0 commit comments

Comments
 (0)