From: Boris Brezillon <boris.brezillon@collabora.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>,
Amit Kucheria <amitk@kernel.org>, Zhang Rui <rui.zhang@intel.com>,
linux-pm@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] thermal/of: Fix a leak in thermal_of_zone_register()
Date: Mon, 28 Aug 2023 10:06:16 +0200 [thread overview]
Message-ID: <20230828100616.7d64c98d@collabora.com> (raw)
In-Reply-To: <CAJZ5v0jZ8By3Mz_JM6O79p0af4GaRBXE4PgiCHVOuHWcf=UQsA@mail.gmail.com>
On Fri, 11 Aug 2023 21:18:39 +0200
"Rafael J. Wysocki" <rafael@kernel.org> wrote:
> On Wed, Aug 9, 2023 at 1:23 PM Boris Brezillon
> <boris.brezillon@collabora.com> wrote:
> >
> > thermal_zone_device_register_with_trips() copies the tzp info. After
> > calling this function, we should free the tzp object, otherwise it's
> > leaked.
> >
> > Fixes: 3d439b1a2ad3 ("thermal/core: Alloc-copy-free the thermal zone parameters structure")
> > Cc: <stable@vger.kernel.org>
> > Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
>
> Hasn't this been fixed in -rc5?
It was indeed. I was based on -rc2 when I tested. Sorry for the noise.
>
> > ---
> > drivers/thermal/thermal_of.c | 11 ++++++++---
> > 1 file changed, 8 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c
> > index 6fb14e521197..e74ef4fa576b 100644
> > --- a/drivers/thermal/thermal_of.c
> > +++ b/drivers/thermal/thermal_of.c
> > @@ -524,10 +524,17 @@ static struct thermal_zone_device *thermal_of_zone_register(struct device_node *
> > tz = thermal_zone_device_register_with_trips(np->name, trips, ntrips,
> > mask, data, of_ops, tzp,
> > pdelay, delay);
> > +
> > + /*
> > + * thermal_zone_device_register_with_trips() copies the tzp info.
> > + * We don't need it after that point.
> > + */
> > + kfree(tzp);
> > +
> > if (IS_ERR(tz)) {
> > ret = PTR_ERR(tz);
> > pr_err("Failed to register thermal zone %pOFn: %d\n", np, ret);
> > - goto out_kfree_tzp;
> > + goto out_kfree_trips;
> > }
> >
> > ret = thermal_zone_device_enable(tz);
> > @@ -540,8 +547,6 @@ static struct thermal_zone_device *thermal_of_zone_register(struct device_node *
> >
> > return tz;
> >
> > -out_kfree_tzp:
> > - kfree(tzp);
> > out_kfree_trips:
> > kfree(trips);
> > out_kfree_of_ops:
> > --
> > 2.41.0
> >
prev parent reply other threads:[~2023-08-28 8:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-09 11:23 [PATCH] thermal/of: Fix a leak in thermal_of_zone_register() Boris Brezillon
2023-08-11 19:18 ` Rafael J. Wysocki
2023-08-28 8:06 ` Boris Brezillon [this message]
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=20230828100616.7d64c98d@collabora.com \
--to=boris.brezillon@collabora.com \
--cc=amitk@kernel.org \
--cc=daniel.lezcano@linaro.org \
--cc=linux-pm@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=rui.zhang@intel.com \
--cc=stable@vger.kernel.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