Commit b0eeba52 authored by Chen Ni's avatar Chen Ni Committed by Linus Walleij
Browse files

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: 32c170ff ("pinctrl: stm32: set default gpio line names using pin names")
Signed-off-by: default avatarChen Ni <nichen@iscas.ac.cn>
Acked-by: default avatarValentin Caron <valentin.caron@foss.st.com>
Link: https://lore.kernel.org/r/20231031080807.3600656-1-nichen@iscas.ac.cn


Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent b85ea95d
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -1368,6 +1368,11 @@ static int stm32_gpiolib_register_bank(struct stm32_pinctrl *pctl, struct fwnode
	}

	names = devm_kcalloc(dev, npins, sizeof(char *), GFP_KERNEL);
	if (!names) {
		err = -ENOMEM;
		goto err_clk;
	}

	for (i = 0; i < npins; i++) {
		stm32_pin = stm32_pctrl_get_desc_pin_from_gpio(pctl, bank, i);
		if (stm32_pin && stm32_pin->pin.name)