[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240912020840.1763252-1-make24@iscas.ac.cn>
Date: Thu, 12 Sep 2024 10:08:40 +0800
From: Ma Ke <make24@...as.ac.cn>
To: marcan@...can.st,
sven@...npeter.dev,
alyssa@...enzweig.io,
linus.walleij@...aro.org,
joey.gouly@....com,
stan@...ellium.com,
maz@...nel.org,
akpm@...ux-foundation.org
Cc: asahi@...ts.linux.dev,
linux-arm-kernel@...ts.infradead.org,
linux-gpio@...r.kernel.org,
linux-kernel@...r.kernel.org,
Ma Ke <make24@...as.ac.cn>,
stable@...r.kernel.org
Subject: [PATCH RESEND] pinctrl: 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@...r.kernel.org
Fixes: a0f160ffcb83 ("pinctrl: add pinctrl/GPIO driver for Apple SoCs")
Signed-off-by: Ma Ke <make24@...as.ac.cn>
---
drivers/pinctrl/pinctrl-apple-gpio.c | 3 +++
1 file changed, 3 insertions(+)
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;
--
2.25.1
Powered by blists - more mailing lists