mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 10:31:46 +09:00
pinctrl: stm32: check devm_kasprintf() returned value
[ Upstream commit b0f0e3f0552a566def55c844b0d44250c58e4df6 ]
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: 32c170ff15 ("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>
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
1a1cfd1456
commit
a8d52de0a6
@@ -1384,10 +1384,15 @@ static int stm32_gpiolib_register_bank(struct stm32_pinctrl *pctl, struct fwnode
|
||||
|
||||
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)
|
||||
if (stm32_pin && stm32_pin->pin.name) {
|
||||
names[i] = devm_kasprintf(dev, GFP_KERNEL, "%s", stm32_pin->pin.name);
|
||||
else
|
||||
if (!names[i]) {
|
||||
err = -ENOMEM;
|
||||
goto err_clk;
|
||||
}
|
||||
} else {
|
||||
names[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bank->gpio_chip.names = (const char * const *)names;
|
||||
|
||||
Reference in New Issue
Block a user