[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251009183735.1288-1-atharvatiwarilinuxdev@gmail.com>
Date: Fri, 10 Oct 2025 00:07:32 +0530
From: Atharva Tiwari <atharvatiwarilinuxdev@...il.com>
To:
Cc: atharvatiwarilinuxdev@...il.com,
Sven Peter <sven@...nel.org>,
Janne Grunau <j@...nau.net>,
Neal Gompa <neal@...pa.dev>,
Linus Walleij <linus.walleij@...aro.org>,
Bartosz Golaszewski <brgl@...ev.pl>,
Sebastian Reichel <sre@...nel.org>,
asahi@...ts.linux.dev,
linux-arm-kernel@...ts.infradead.org,
linux-gpio@...r.kernel.org,
linux-kernel@...r.kernel.org,
linux-pm@...r.kernel.org
Subject: [PATCH] macsmc: check for missing SMC to avoid crash
Users might manually install these drivers
without the core SMC device, causing
a NULL deref. Add a guard and return -ENODEV.
Signed-off-by: Atharva Tiwari <atharvatiwarilinuxdev@...il.com>
---
drivers/gpio/gpio-macsmc.c | 3 +++
drivers/power/reset/macsmc-reboot.c | 3 +++
2 files changed, 6 insertions(+)
diff --git a/drivers/gpio/gpio-macsmc.c b/drivers/gpio/gpio-macsmc.c
index 30ef258e7655..7048b45953bb 100644
--- a/drivers/gpio/gpio-macsmc.c
+++ b/drivers/gpio/gpio-macsmc.c
@@ -238,6 +238,9 @@ static int macsmc_gpio_probe(struct platform_device *pdev)
smc_key key;
int ret;
+ if (!smc)
+ return -ENODEV;
+
smcgp = devm_kzalloc(&pdev->dev, sizeof(*smcgp), GFP_KERNEL);
if (!smcgp)
return -ENOMEM;
diff --git a/drivers/power/reset/macsmc-reboot.c b/drivers/power/reset/macsmc-reboot.c
index e9702acdd366..739f94e4ed7e 100644
--- a/drivers/power/reset/macsmc-reboot.c
+++ b/drivers/power/reset/macsmc-reboot.c
@@ -205,6 +205,9 @@ static int macsmc_reboot_probe(struct platform_device *pdev)
struct macsmc_reboot *reboot;
int ret, i;
+ if (!smc)
+ return -ENODEV;
+
reboot = devm_kzalloc(&pdev->dev, sizeof(*reboot), GFP_KERNEL);
if (!reboot)
return -ENOMEM;
--
2.43.0
Powered by blists - more mailing lists