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

memory: tegra: Delete unneeded of_node_put()

for_each_child_of_node() performs an of_node_put() on each iteration, so
putting an of_node_put() before a continue results in a double put.

The semantic match that finds this problem is as follows
(http://coccinelle.lip6.fr):

// <smpl>
@@
expression root,e;
local idexpression child;
iterator name for_each_child_of_node;
@@

for_each_child_of_node(root, child) {
... when != of_node_get(child)
* of_node_put(child);
...
* continue;
}
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Thierry Reding <treding@nvidia.com>

authored by

Julia Lawall and committed by
Thierry Reding
d1122e4b aafb197f

+2 -6
+1 -3
drivers/memory/tegra/mc.c
··· 206 206 for_each_child_of_node(mc->dev->of_node, node) { 207 207 err = of_property_read_u32(node, "nvidia,ram-code", 208 208 &node_ram_code); 209 - if (err || (node_ram_code != ram_code)) { 210 - of_node_put(node); 209 + if (err || (node_ram_code != ram_code)) 211 210 continue; 212 - } 213 211 214 212 err = load_timings(mc, node); 215 213 if (err)
+1 -3
drivers/memory/tegra/tegra124-emc.c
··· 997 997 u32 value; 998 998 999 999 err = of_property_read_u32(np, "nvidia,ram-code", &value); 1000 - if (err || (value != ram_code)) { 1001 - of_node_put(np); 1000 + if (err || (value != ram_code)) 1002 1001 continue; 1003 - } 1004 1002 1005 1003 return np; 1006 1004 }