diff options
author | Ma Ke <make24@iscas.ac.cn> | 2024-09-06 18:03:26 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2024-10-22 15:46:34 +0200 |
commit | 3b36bb1fca2b87f6292ca2a8593f297c5e9fab41 (patch) | |
tree | 8c2ff2e1be642f8943765d3d89a9a85054d9751d /drivers/pinctrl | |
parent | 20728e86289ab463b99b7ab4425515bd26aba417 (diff) | |
download | linux-rpi-3b36bb1fca2b87f6292ca2a8593f297c5e9fab41.tar.gz linux-rpi-3b36bb1fca2b87f6292ca2a8593f297c5e9fab41.tar.bz2 linux-rpi-3b36bb1fca2b87f6292ca2a8593f297c5e9fab41.zip |
pinctrl: stm32: check devm_kasprintf() returned value
commit b0f0e3f0552a566def55c844b0d44250c58e4df6 upstream.
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: 32c170ff15b0 ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/pinctrl')
-rw-r--r-- | drivers/pinctrl/stm32/pinctrl-stm32.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/pinctrl/stm32/pinctrl-stm32.c b/drivers/pinctrl/stm32/pinctrl-stm32.c index 346a31f31bba..5e91def60784 100644 --- a/drivers/pinctrl/stm32/pinctrl-stm32.c +++ b/drivers/pinctrl/stm32/pinctrl-stm32.c @@ -1387,10 +1387,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; |