Skip to content

Commit acf40ab

Browse files
Charles Hanlinusw
authored andcommitted
pinctrl: nuvoton: npcm8xx: Add NULL check in npcm8xx_gpio_fw
devm_kasprintf() calls can return null pointers on failure. But the return values were not checked in npcm8xx_gpio_fw(). Add NULL check in npcm8xx_gpio_fw(), to handle kernel NULL pointer dereference error. Fixes: acf4884 ("pinctrl: nuvoton: add NPCM8XX pinctrl and GPIO driver") Signed-off-by: Charles Han <hanchunchao@inspur.com> Link: https://lore.kernel.org/20250212100532.4317-1-hanchunchao@inspur.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent 68283c1 commit acf40ab

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2374,6 +2374,9 @@ static int npcm8xx_gpio_fw(struct npcm8xx_pinctrl *pctrl)
23742374
pctrl->gpio_bank[id].gc.parent = dev;
23752375
pctrl->gpio_bank[id].gc.fwnode = child;
23762376
pctrl->gpio_bank[id].gc.label = devm_kasprintf(dev, GFP_KERNEL, "%pfw", child);
2377+
if (pctrl->gpio_bank[id].gc.label == NULL)
2378+
return -ENOMEM;
2379+
23772380
pctrl->gpio_bank[id].gc.dbg_show = npcmgpio_dbg_show;
23782381
pctrl->gpio_bank[id].direction_input = pctrl->gpio_bank[id].gc.direction_input;
23792382
pctrl->gpio_bank[id].gc.direction_input = npcmgpio_direction_input;

0 commit comments

Comments
 (0)