[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAJZ5v0g4d234zx9Ts9wAgAbokTtQWqkCFU7CtKwzPJ_T=xXv1Q@mail.gmail.com>
Date: Wed, 28 Jan 2026 22:11:57 +0100
From: "Rafael J. Wysocki" <rafael@...nel.org>
To: Lukasz Luba <lukasz.luba@....com>, Felix Gu <ustc.gu@...il.com>,
Daniel Lezcano <daniel.lezcano@...aro.org>
Cc: Zhang Rui <rui.zhang@...el.com>, Yu-Che Cheng <giver@...omium.org>, linux-pm@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] thermal/of: Fix reference leak in thermal_of_cm_lookup()
On Wed, Jan 28, 2026 at 11:42 AM Lukasz Luba <lukasz.luba@....com> wrote:
>
>
>
> On 1/27/26 16:22, Rafael J. Wysocki wrote:
> > On Fri, Jan 23, 2026 at 8:06 PM Felix Gu <ustc.gu@...il.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@...il.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@....com>
Applied as 6.20 material, thanks!
Powered by blists - more mailing lists