Skip to content

Commit b0f0e3f

Browse files
Ma Kelinusw
authored andcommitted
pinctrl: stm32: check devm_kasprintf() returned value
devm_kasprintf() can return a NULL pointer on failure but this returned value is not checked. Fix this lack and check the returned value. Found by code review. Cc: stable@vger.kernel.org Fixes: 32c170f ("pinctrl: stm32: set default gpio line names using pin names") Signed-off-by: Ma Ke <make24@iscas.ac.cn> Link: https://lore.kernel.org/20240906100326.624445-1-make24@iscas.ac.cn Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent 665a58f commit b0f0e3f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

drivers/pinctrl/stm32/pinctrl-stm32.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,10 +1374,15 @@ static int stm32_gpiolib_register_bank(struct stm32_pinctrl *pctl, struct fwnode
13741374

13751375
for (i = 0; i < npins; i++) {
13761376
stm32_pin = stm32_pctrl_get_desc_pin_from_gpio(pctl, bank, i);
1377-
if (stm32_pin && stm32_pin->pin.name)
1377+
if (stm32_pin && stm32_pin->pin.name) {
13781378
names[i] = devm_kasprintf(dev, GFP_KERNEL, "%s", stm32_pin->pin.name);
1379-
else
1379+
if (!names[i]) {
1380+
err = -ENOMEM;
1381+
goto err_clk;
1382+
}
1383+
} else {
13801384
names[i] = NULL;
1385+
}
13811386
}
13821387

13831388
bank->gpio_chip.names = (const char * const *)names;

0 commit comments

Comments
 (0)