This series releases the 'soc' device_node when it is no longer required by adding the missing calls to of_node_put() to make the fix compatible with all affected stable kernels. Then, the more robust approach via cleanup attribute is used to simplify the handling and prevent issues if the loop gets new execution paths.
These issues were found while analyzing the code, and the patches have been successfully compiled, but not tested on real hardware as I don't have access to it. Any volunteering for testing is always more than welcome.
Signed-off-by: Javier Carrasco javier.carrasco.cruz@gmail.com --- Javier Carrasco (2): clk: renesas: cpg-mssr: fix 'soc' node handling in cpg_mssr_reserved_init() clk: renesas: cpg-mssr: automate 'soc' node release in cpg_mssr_reserved_init()
drivers/clk/renesas/renesas-cpg-mssr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- base-commit: 86e3904dcdc7e70e3257fc1de294a1b75f3d8d04 change-id: 20241031-clk-renesas-cpg-mssr-cleanup-1933df63bc9c
Best regards,
A device_node reference obtained via of_find_node_by_path() requires explicit calls to of_node_put() after it is no longer required to avoid leaking the resource.
Add the missing calls to of_node_put(soc) in all execution paths when 'soc' is no longer required (one error path, and the success path).
Cc: stable@vger.kernel.org Fixes: 6aa175476490 ("clk: renesas: cpg-mssr: Ignore all clocks assigned to non-Linux system") Signed-off-by: Javier Carrasco javier.carrasco.cruz@gmail.com --- drivers/clk/renesas/renesas-cpg-mssr.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/drivers/clk/renesas/renesas-cpg-mssr.c b/drivers/clk/renesas/renesas-cpg-mssr.c index 79e7a90c3b1b..5dc89b1009fe 100644 --- a/drivers/clk/renesas/renesas-cpg-mssr.c +++ b/drivers/clk/renesas/renesas-cpg-mssr.c @@ -1022,6 +1022,7 @@ static int __init cpg_mssr_reserved_init(struct cpg_mssr_priv *priv,
ids = krealloc_array(ids, (num + 1), sizeof(*ids), GFP_KERNEL); if (!ids) { + of_node_put(soc); of_node_put(it.node); return -ENOMEM; } @@ -1036,6 +1037,7 @@ static int __init cpg_mssr_reserved_init(struct cpg_mssr_priv *priv, num++; } } + of_node_put(soc);
priv->num_reserved_ids = num; priv->reserved_ids = ids;
linux-stable-mirror@lists.linaro.org