summaryrefslogtreecommitdiff
path: root/drivers/pinctrl
diff options
context:
space:
mode:
authorMa Ke <make24@iscas.ac.cn>2024-09-05 10:09:17 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-10-22 15:46:34 +0200
commitfad940e2dd789155f99ecafa71a7baf6f96530bc (patch)
tree665ecd09f5e6e9f3bdd61d2f37eb7801cb4dbec5 /drivers/pinctrl
parent3b36bb1fca2b87f6292ca2a8593f297c5e9fab41 (diff)
downloadlinux-rpi-fad940e2dd789155f99ecafa71a7baf6f96530bc.tar.gz
linux-rpi-fad940e2dd789155f99ecafa71a7baf6f96530bc.tar.bz2
linux-rpi-fad940e2dd789155f99ecafa71a7baf6f96530bc.zip
pinctrl: apple: check devm_kasprintf() returned value
commit 665a58fe663ac7a9ea618dc0b29881649324b116 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: a0f160ffcb83 ("pinctrl: add pinctrl/GPIO driver for Apple SoCs") Signed-off-by: Ma Ke <make24@iscas.ac.cn> Reviewed-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Link: https://lore.kernel.org/20240905020917.356534-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/pinctrl-apple-gpio.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/pinctrl/pinctrl-apple-gpio.c b/drivers/pinctrl/pinctrl-apple-gpio.c
index 3751c7de37aa..f861e63f4115 100644
--- a/drivers/pinctrl/pinctrl-apple-gpio.c
+++ b/drivers/pinctrl/pinctrl-apple-gpio.c
@@ -474,6 +474,9 @@ static int apple_gpio_pinctrl_probe(struct platform_device *pdev)
for (i = 0; i < npins; i++) {
pins[i].number = i;
pins[i].name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "PIN%u", i);
+ if (!pins[i].name)
+ return -ENOMEM;
+
pins[i].drv_data = pctl;
pin_names[i] = pins[i].name;
pin_nums[i] = i;