* [PATCH] macsmc: check for missing SMC to avoid crash
@ 2025-10-09 18:37 Atharva Tiwari
2025-10-09 18:56 ` Sven Peter
0 siblings, 1 reply; 2+ messages in thread
From: Atharva Tiwari @ 2025-10-09 18:37 UTC (permalink / raw)
Cc: atharvatiwarilinuxdev, Sven Peter, Janne Grunau, Neal Gompa,
Linus Walleij, Bartosz Golaszewski, Sebastian Reichel, asahi,
linux-arm-kernel, linux-gpio, linux-kernel, linux-pm
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@gmail.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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] macsmc: check for missing SMC to avoid crash
2025-10-09 18:37 [PATCH] macsmc: check for missing SMC to avoid crash Atharva Tiwari
@ 2025-10-09 18:56 ` Sven Peter
0 siblings, 0 replies; 2+ messages in thread
From: Sven Peter @ 2025-10-09 18:56 UTC (permalink / raw)
To: Atharva Tiwari
Cc: Janne Grunau, Neal Gompa, Linus Walleij, Bartosz Golaszewski,
Sebastian Reichel, asahi, linux-arm-kernel, linux-gpio,
linux-kernel, linux-pm
On 09.10.25 20:37, Atharva Tiwari wrote:
> Users might manually install these drivers
> without the core SMC device, causing
Installing isn't enough; that's not gonna trigger probing any of these
devices.
Did you run into this issue?
Hitting this should require deliberately creating a broken dts file and
booting with that one. But if I'm creating a broken dts file I can
easily crash the kernel in various other ways.
Sven
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-10-09 18:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-09 18:37 [PATCH] macsmc: check for missing SMC to avoid crash Atharva Tiwari
2025-10-09 18:56 ` Sven Peter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).