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

gpu: host1x: bus: Add missing of_node_put()

for_each_child_of_node() performs an of_node_get() on each iteration, so
to break 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 n;
@@

for_each_child_of_node(..., n) {
... when != of_node_put(n)
when != e = n
(
return n;
|
+ of_node_put(n);
? 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
93ec3029 92e963f5

+3 -1
+3 -1
drivers/gpu/host1x/bus.c
··· 82 82 if (of_match_node(driver->subdevs, np) && 83 83 of_device_is_available(np)) { 84 84 err = host1x_subdev_add(device, np); 85 - if (err < 0) 85 + if (err < 0) { 86 + of_node_put(np); 86 87 return err; 88 + } 87 89 } 88 90 } 89 91