Skip to content

Commit b0eeba5

Browse files
Chen NiLinus Walleij
authored andcommitted
pinctrl: stm32: Add check for devm_kcalloc
Add check for the return value of devm_kcalloc() and return the error if it fails in order to avoid NULL pointer dereference. Fixes: 32c170f ("pinctrl: stm32: set default gpio line names using pin names") Signed-off-by: Chen Ni <nichen@iscas.ac.cn> Acked-by: Valentin Caron <valentin.caron@foss.st.com> Link: https://lore.kernel.org/r/20231031080807.3600656-1-nichen@iscas.ac.cn Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent b85ea95 commit b0eeba5

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

drivers/pinctrl/stm32/pinctrl-stm32.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,6 +1368,11 @@ static int stm32_gpiolib_register_bank(struct stm32_pinctrl *pctl, struct fwnode
13681368
}
13691369

13701370
names = devm_kcalloc(dev, npins, sizeof(char *), GFP_KERNEL);
1371+
if (!names) {
1372+
err = -ENOMEM;
1373+
goto err_clk;
1374+
}
1375+
13711376
for (i = 0; i < npins; i++) {
13721377
stm32_pin = stm32_pctrl_get_desc_pin_from_gpio(pctl, bank, i);
13731378
if (stm32_pin && stm32_pin->pin.name)

0 commit comments

Comments
 (0)