]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
pinctrl: apple: check devm_kasprintf() returned value
authorMa Ke <make24@iscas.ac.cn>
Thu, 5 Sep 2024 02:09:17 +0000 (10:09 +0800)
committerLinus Walleij <linus.walleij@linaro.org>
Tue, 1 Oct 2024 12:03:34 +0000 (14:03 +0200)
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>
drivers/pinctrl/pinctrl-apple-gpio.c

index 3751c7de37aa9fc48c5708742db9e908ca2b61e3..f861e63f41152109f53bb6479f390c2e414d3fd6 100644 (file)
@@ -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;