Skip to content

Commit

Permalink
net: dsa: vsc73xx: Add null pointer check to vsc73xx_gpio_probe
Browse files Browse the repository at this point in the history
[ Upstream commit 776dac5 ]

devm_kasprintf() returns a pointer to dynamically allocated memory
which can be NULL upon failure.

Fixes: 05bd97f ("net: dsa: Add Vitesse VSC73xx DSA router driver")
Signed-off-by: Kunwu Chan <[email protected]>
Suggested-by: Jakub Kicinski <[email protected]>
Reviewed-by: Simon Horman <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
KunWuChan authored and gregkh committed Jan 25, 2024
1 parent 1b500d5 commit 91f9eca
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/net/dsa/vitesse-vsc73xx-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1135,6 +1135,8 @@ static int vsc73xx_gpio_probe(struct vsc73xx *vsc)

vsc->gc.label = devm_kasprintf(vsc->dev, GFP_KERNEL, "VSC%04x",
vsc->chipid);
if (!vsc->gc.label)
return -ENOMEM;
vsc->gc.ngpio = 4;
vsc->gc.owner = THIS_MODULE;
vsc->gc.parent = vsc->dev;
Expand Down

0 comments on commit 91f9eca

Please sign in to comment.