Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Commit

Permalink
pinctrl: apple: check devm_kasprintf() returned value
Browse files Browse the repository at this point in the history
commit 665a58f 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: [email protected]
Fixes: a0f160f ("pinctrl: add pinctrl/GPIO driver for Apple SoCs")
Signed-off-by: Ma Ke <[email protected]>
Reviewed-by: Christophe JAILLET <[email protected]>
Link: https://lore.kernel.org/[email protected]
Signed-off-by: Linus Walleij <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Ma Ke authored and gregkh committed Oct 22, 2024
1 parent 1f26695 commit 4d2296f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/pinctrl/pinctrl-apple-gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 4d2296f

Please sign in to comment.