mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH master] pmdomain: fix NULL pointer derference with dummy power domains
@ 2025-12-01 13:37 Ahmad Fatoum
  0 siblings, 0 replies; only message in thread
From: Ahmad Fatoum @ 2025-12-01 13:37 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

With the addition of commit 4aca68990d04 ("drivers: power: ignore power
domains with barebox,allow-dummy"), it's possible for genpd to be NULL
when there is no driver and the device tree node has barebox,allow-dummy
in it.

Allow for this possibility in genpd_add_device and genpd_remove_device
as well.

Fixes: 44c6bedbd439 ("pmdomain: allow callback for when devices are attached")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
Issue is in master, but has not yet hit a release.
Needed also on next to fix CI breakage as the issue became visible only
after in-tree boards started using barebox,allow-dummy.
---
 drivers/base/power.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/base/power.c b/drivers/base/power.c
index 668b835df3e6..c71389422a53 100644
--- a/drivers/base/power.c
+++ b/drivers/base/power.c
@@ -335,7 +335,7 @@ static int genpd_add_device(struct generic_pm_domain *genpd, struct device *dev)
 {
 	dev->pm_domain = genpd;
 
-	if (genpd->attach_dev)
+	if (genpd && genpd->attach_dev)
 		return genpd->attach_dev(genpd, dev);
 
 	return 0;
@@ -344,7 +344,7 @@ static int genpd_add_device(struct generic_pm_domain *genpd, struct device *dev)
 static void genpd_remove_device(struct generic_pm_domain *genpd,
 			       struct device *dev)
 {
-	if (genpd->detach_dev)
+	if (genpd && genpd->detach_dev)
 		genpd->detach_dev(genpd, dev);
 
 	dev->pm_domain = NULL;
-- 
2.47.3




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-12-01 13:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-01 13:37 [PATCH master] pmdomain: fix NULL pointer derference with dummy power domains Ahmad Fatoum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox