From: Lukasz Luba <lukasz.luba@arm.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>, Felix Gu <ustc.gu@gmail.com>
Cc: Zhang Rui <rui.zhang@intel.com>,
Yu-Che Cheng <giver@chromium.org>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] thermal/of: Fix reference leak in thermal_of_cm_lookup()
Date: Wed, 28 Jan 2026 10:42:48 +0000 [thread overview]
Message-ID: <67d1584c-a474-4873-8cc2-9899296ea7ea@arm.com> (raw)
In-Reply-To: <CAJZ5v0gL92f3g4oj47jaYQKG_V6vd_oBawbwQVWjUP7u9QKS7g@mail.gmail.com>
On 1/27/26 16:22, Rafael J. Wysocki wrote:
> On Fri, Jan 23, 2026 at 8:06 PM Felix Gu <ustc.gu@gmail.com> wrote:
>>
>> In thermal_of_cm_lookup(), tr_np is obtained via of_parse_phandle(). But
>> it never be released.
>> Use the __free(device_node) cleanup attribute to automatically release
>> the node and fix the leak.
>>
>> Fixes: 423de5b5bc5b ("thermal/of: Fix cdev lookup in thermal_of_should_bind()")
>>
>> Signed-off-by: Felix Gu <ustc.gu@gmail.com>
>> ---
>> drivers/thermal/thermal_of.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c
>> index 1a51a4d240ff..b6d0c92f5522 100644
>> --- a/drivers/thermal/thermal_of.c
>> +++ b/drivers/thermal/thermal_of.c
>> @@ -280,10 +280,10 @@ static bool thermal_of_cm_lookup(struct device_node *cm_np,
>> struct cooling_spec *c)
>> {
>> for_each_child_of_node_scoped(cm_np, child) {
>> - struct device_node *tr_np;
>> int count, i;
>>
>> - tr_np = of_parse_phandle(child, "trip", 0);
>> + struct device_node *tr_np __free(device_node) =
>> + of_parse_phandle(child, "trip", 0);
>> if (tr_np != trip->priv)
>> continue;
>>
>>
>> ---
>
> This looks good to me.
>
> Lukasz, Daniel?
Good catch thanks! That looks good. This scoped device node
handling approach simplifies a lot the error paths (and is less
error-prone).
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
next prev parent reply other threads:[~2026-01-28 10:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-23 19:06 [PATCH] thermal/of: Fix reference leak in thermal_of_cm_lookup() Felix Gu
2026-01-27 16:22 ` Rafael J. Wysocki
2026-01-28 10:42 ` Lukasz Luba [this message]
2026-01-28 21:11 ` Rafael J. Wysocki
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=67d1584c-a474-4873-8cc2-9899296ea7ea@arm.com \
--to=lukasz.luba@arm.com \
--cc=daniel.lezcano@linaro.org \
--cc=giver@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=rui.zhang@intel.com \
--cc=ustc.gu@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