Re: [PATCH 2/2] thermal: of: fix double-free on unregistration

From: Daniel Lezcano
Date: Thu Jul 13 2023 - 08:53:14 EST


On 11/07/2023 20:05, Rafael J. Wysocki wrote:
On Sat, Jul 8, 2023 at 1:27 PM Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx> wrote:

Since commit 3d439b1a2ad3 ("thermal/core: Alloc-copy-free the thermal
zone parameters structure"), thermal_zone_device_register() allocates
a copy of the tzp argument and frees it when unregistering, so
thermal_of_zone_register() now ends up leaking its original tzp and
double-freeing the tzp copy. Fix this by locating tzp on stack instead.

Fixes: 3d439b1a2ad3 ("thermal/core: Alloc-copy-free the thermal zone parameters structure")
Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>

Daniel, this looks like a genuine fix to me, so I'm inclined to pick
it up directly.

Any objections?


No objection

Acked-by: Daniel Lezcano <daniel.lezcano@xxxxxxxxxx>

--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog