From: Felix Gu <ustc.gu@gmail.com>
To: Andrew Lunn <andrew@lunn.ch>,
Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>,
Gregory Clement <gregory.clement@bootlin.com>,
Russell King <rmk+kernel@arm.linux.org.uk>
Cc: linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Felix Gu <ustc.gu@gmail.com>
Subject: [PATCH] soc: dove: pmu: Fix device node reference leaks in dove_init_pmu()
Date: Sat, 31 Jan 2026 22:21:08 +0800 [thread overview]
Message-ID: <20260131-dove_pmu-v1-1-1b40989778d1@gmail.com> (raw)
Use __free(device_node) cleanup attribute for domains_node and add
missing of_node_put(np_pmu) calls in error paths to prevent device
node reference leaks.
Fixes: 44e259ac909f ("ARM: dove: create a proper PMU driver for power domains, PMU IRQs and resets")Y
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
---
drivers/soc/dove/pmu.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/soc/dove/pmu.c b/drivers/soc/dove/pmu.c
index dd8ade8e9ee8..3b2567f20649 100644
--- a/drivers/soc/dove/pmu.c
+++ b/drivers/soc/dove/pmu.c
@@ -371,7 +371,7 @@ int __init dove_init_pmu_legacy(const struct dove_pmu_initdata *initdata)
*/
int __init dove_init_pmu(void)
{
- struct device_node *np_pmu, *domains_node;
+ struct device_node *np_pmu;
struct pmu_data *pmu;
int ret, parent_irq;
@@ -380,15 +380,19 @@ int __init dove_init_pmu(void)
if (!np_pmu)
return 0;
- domains_node = of_get_child_by_name(np_pmu, "domains");
+ struct device_node *domains_node __free(device_node) =
+ of_get_child_by_name(np_pmu, "domains");
if (!domains_node) {
pr_err("%pOFn: failed to find domains sub-node\n", np_pmu);
+ of_node_put(np_pmu);
return 0;
}
pmu = kzalloc(sizeof(*pmu), GFP_KERNEL);
- if (!pmu)
+ if (!pmu) {
+ of_node_put(np_pmu);
return -ENOMEM;
+ }
spin_lock_init(&pmu->lock);
pmu->of_node = np_pmu;
@@ -399,6 +403,7 @@ int __init dove_init_pmu(void)
iounmap(pmu->pmu_base);
iounmap(pmu->pmc_base);
kfree(pmu);
+ of_node_put(np_pmu);
return -ENOMEM;
}
---
base-commit: 33a647c659ffa5bdb94abc345c8c86768ff96215
change-id: 20260131-dove_pmu-83fa64fb16ed
Best regards,
--
Felix Gu <ustc.gu@gmail.com>
next reply other threads:[~2026-01-31 14:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-31 14:21 Felix Gu [this message]
2026-02-01 9:24 ` Markus Elfring
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=20260131-dove_pmu-v1-1-1b40989778d1@gmail.com \
--to=ustc.gu@gmail.com \
--cc=andrew@lunn.ch \
--cc=gregory.clement@bootlin.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rmk+kernel@arm.linux.org.uk \
--cc=sebastian.hesselbarth@gmail.com \
/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
all inboxes | Powered by JetHome®