mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 10:31:46 +09:00
pinctrl: stm32: Add check for devm_kcalloc
[ Upstream commit b0eeba527e704d6023a6cd9103f929226e326b03 ]
Add check for the return value of devm_kcalloc() and return the error
if it fails in order to avoid NULL pointer dereference.
Fixes: 32c170ff15 ("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>
Stable-dep-of: 451bc9aea9a1 ("pinctrl: stm32: Add check for clk_enable()")
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
75285cb2b4
commit
1a1cfd1456
@@ -1377,6 +1377,11 @@ static int stm32_gpiolib_register_bank(struct stm32_pinctrl *pctl, struct fwnode
|
|||||||
}
|
}
|
||||||
|
|
||||||
names = devm_kcalloc(dev, npins, sizeof(char *), GFP_KERNEL);
|
names = devm_kcalloc(dev, npins, sizeof(char *), GFP_KERNEL);
|
||||||
|
if (!names) {
|
||||||
|
err = -ENOMEM;
|
||||||
|
goto err_clk;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < npins; i++) {
|
for (i = 0; i < npins; i++) {
|
||||||
stm32_pin = stm32_pctrl_get_desc_pin_from_gpio(pctl, bank, i);
|
stm32_pin = stm32_pctrl_get_desc_pin_from_gpio(pctl, bank, i);
|
||||||
if (stm32_pin && stm32_pin->pin.name)
|
if (stm32_pin && stm32_pin->pin.name)
|
||||||
|
|||||||
Reference in New Issue
Block a user