From: Xixin Liu <liuxixin@kylinos.cn>
To: arm-scmi@vger.kernel.org
Cc: sudeep.holla@arm.com, cristian.marussi@arm.com,
mturquette@baylibre.com, sboyd@kernel.org,
linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org,
linux-kernel@vger.kernel.org, liuxixin@kylinos.cn
Subject: [PATCH v1 1/4] firmware: arm_scpi: fix device_node leak in scpi_dev_domain_id
Date: Mon, 27 Jul 2026 10:19:14 +0800 [thread overview]
Message-ID: <fe59f1badf4f.1785118770.git.liuxixin@kylinos.cn> (raw)
In-Reply-To: <cover.1785118770.git.liuxixin@kylinos.cn>
of_parse_phandle_with_args() takes a reference on clkspec.np that must be
released with of_node_put(). scpi_dev_domain_id() returned clkspec.args[0]
without dropping that reference, so every domain lookup leaked a device
node. Paths such as scpi_dvfs_info() / cpufreq init call this per CPU, so
the leak accumulates over time.
Save the domain id, of_node_put(clkspec.np), then return the saved value.
Signed-off-by: Xixin Liu <liuxixin@kylinos.cn>
---
drivers/firmware/arm_scpi.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/firmware/arm_scpi.c b/drivers/firmware/arm_scpi.c
index 87c323de17b9..6056754ef48c 100644
--- a/drivers/firmware/arm_scpi.c
+++ b/drivers/firmware/arm_scpi.c
@@ -660,12 +660,15 @@ static struct scpi_dvfs_info *scpi_dvfs_get_info(u8 domain)
static int scpi_dev_domain_id(struct device *dev)
{
struct of_phandle_args clkspec;
+ int domain;
if (of_parse_phandle_with_args(dev->of_node, "clocks", "#clock-cells",
0, &clkspec))
return -EINVAL;
- return clkspec.args[0];
+ domain = clkspec.args[0];
+ of_node_put(clkspec.np);
+ return domain;
}
static struct scpi_dvfs_info *scpi_dvfs_info(struct device *dev)
--
2.53.0
next prev parent reply other threads:[~2026-07-27 2:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-27 2:19 [PATCH v1 0/4] firmware/clk: arm_scpi hardening (leak, OPP bounds, cpufreq) Xixin Liu
2026-07-27 2:19 ` Xixin Liu [this message]
2026-07-27 2:19 ` [PATCH v1 4/4] clk: scpi: register scpi-cpufreq once and clear on failure Xixin Liu
2026-07-27 2:19 ` [PATCH v1 2/4] firmware: arm_scpi: reject DVFS OPP count above MAX_DVFS_OPPS Xixin Liu
2026-07-27 2:19 ` [PATCH v1 3/4] clk: scpi: bound-check DVFS index in scpi_dvfs_recalc_rate Xixin Liu
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=fe59f1badf4f.1785118770.git.liuxixin@kylinos.cn \
--to=liuxixin@kylinos.cn \
--cc=arm-scmi@vger.kernel.org \
--cc=cristian.marussi@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=sboyd@kernel.org \
--cc=sudeep.holla@arm.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