From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH master] pmdomain: fix NULL pointer derference with dummy power domains
Date: Mon, 1 Dec 2025 14:37:47 +0100 [thread overview]
Message-ID: <20251201133832.3303902-1-a.fatoum@pengutronix.de> (raw)
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
reply other threads:[~2025-12-01 13:39 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251201133832.3303902-1-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox