Re: [PATCH 0/2] cpufreq: sun50i: fix memory leak and remove of_node_put()

From: Viresh Kumar
Date: Mon May 20 2024 - 05:32:49 EST


On 03-05-24, 19:52, Javier Carrasco wrote:
> This series fixes a memory leak by means of the _scoped version of the
> for_each_child_of_node() loop, which was recently introduced with
> 34af4554fb0c ("of: Introduce for_each_*_child_of_node_scoped() to
> automate of_node_put() handling").
>
> The new approach is still not widely used, but this might be a good
> occasion to use it in a driver because it actually fixes a bug, and
> the loop is rather simple.
>
> The creator of the new macro was added to the discussion in case the
> new approach is still not mature enough, even for such simple case.
>
> Additionally, the existing uses of of_node_put() have been removed to
> favour the _free() cleanup handler, which reduces the chances of having
> any other memory leak because some of_node_put() is missing as well as
> simplifies the current code.
>
> I don't have the real hardware to test the series, so I "faked" the node
> in a device tree for an arm64 device (Rockchip) and hacked the driver
> to get to run dt_has_supported_hw(). The new implementation works as
> expected, but if someone wants to test it with the proper SoC,
> additional tests are always welcome. The same applies for the removals
> of of_node_put().
>
> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@xxxxxxxxx>
> ---
> Javier Carrasco (2):
> cpufreq: sun50i: fix memory leak in dt_has_supported_hw()
> cpufreq: sun50i: replace of_node_put() with automatic cleanup handler

Applied. Thanks.

--
viresh