Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: tegra: Add missing of_node_put()

for_each_child_of_node() performs an of_node_get() on each iteration, so
before breaking out of the loop an of_node_put() is required.

Found using Coccinelle. The semantic patch used for this is as follows:

// <smpl>
@@
expression e;
local idexpression child;
@@

for_each_child_of_node(root, child) {
... when != of_node_put(child)
when != e = child
(
return child;
|
+ of_node_put(child);
? return ...;
)
...
}
// </smpl>

Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>

authored by

Amitoj Kaur Chawla and committed by
Thierry Reding
047d6d84 442f53fb

+4 -2
+4 -2
drivers/clk/tegra/clk-emc.c
··· 450 450 struct emc_timing *timing = tegra->timings + (i++); 451 451 452 452 err = load_one_timing_from_dt(tegra, timing, child); 453 - if (err) 453 + if (err) { 454 + of_node_put(child); 454 455 return err; 456 + } 455 457 456 458 timing->ram_code = ram_code; 457 459 } ··· 501 499 * fuses until the apbmisc driver is loaded. 502 500 */ 503 501 err = load_timings_from_dt(tegra, node, node_ram_code); 502 + of_node_put(node); 504 503 if (err) 505 504 return ERR_PTR(err); 506 - of_node_put(node); 507 505 break; 508 506 } 509 507