Skip to content

Commit 665a58f

Browse files
Ma Kelinusw
authored andcommitted
pinctrl: apple: check devm_kasprintf() returned value
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: a0f160f ("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>
1 parent 9852d85 commit 665a58f

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/pinctrl/pinctrl-apple-gpio.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,9 @@ static int apple_gpio_pinctrl_probe(struct platform_device *pdev)
474474
for (i = 0; i < npins; i++) {
475475
pins[i].number = i;
476476
pins[i].name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "PIN%u", i);
477+
if (!pins[i].name)
478+
return -ENOMEM;
479+
477480
pins[i].drv_data = pctl;
478481
pin_names[i] = pins[i].name;
479482
pin_nums[i] = i;

0 commit comments

Comments
 (0)