Skip to contentSkip to conversation

of: overlay: fix for_each_child.cocci warnings

PATCH Applied Julia Lawall 3 participants 3 messages Mar 22, 2021 – Mar 24, 2021 Device tree

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 of: overlay: fix for_each_child.cocci warnings

From: kernel test robot <[email protected]>

Function "for_each_child_of_node" should have of_node_put() before goto.

Generated by: scripts/coccinelle/iterators/for_each_child.cocci

Fixes 82c2d81361ec ("coccinelle: iterators: Add for_each_child.cocci script")
CC Sumera Priyadarsini <[email protected]>

---

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   812da4d39463a060738008a46cfc9f775e4bfcf6
commit: 82c2d81361ecd142a54e84a9da1e287113314a4f coccinelle: iterators: Add for_each_child.cocci script

:::::: branch date: 13 hours ago
:::::: commit date: 5 months ago

 overlay.c |    1 +
 1 file changed, 1 insertion(+)
drivers/of/overlay.c +1 -0
@@ -796,6 +796,7 @@ static int init_overlay_changeset(struct
 		if (!fragment->target) {
 			of_node_put(fragment->overlay);
 			ret = -EINVAL;
+			of_node_put(node);
 			goto err_free_fragments;
 		}
Reviewed-by Tested-by on v1 1/1
#1 lore raw
Quoted 25 lines · Julia Lawall

From: kernel test robot <[email protected]>

Function "for_each_child_of_node" should have of_node_put() before goto.

Generated by: scripts/coccinelle/iterators/for_each_child.cocci

Fixes 82c2d81361ec ("coccinelle: iterators: Add for_each_child.cocci script")
CC Sumera Priyadarsini <[email protected]>

---

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   812da4d39463a060738008a46cfc9f775e4bfcf6
commit: 82c2d81361ecd142a54e84a9da1e287113314a4f coccinelle: iterators: Add for_each_child.cocci script

:::::: branch date: 13 hours ago
:::::: commit date: 5 months ago

 overlay.c |    1 +
 1 file changed, 1 insertion(+)

drivers/of/overlay.c static int init_overlay_changeset(struct · line 802

Quoted 7 lines
drivers/of/overlay.c +1 -0
@@ -796,6 +796,7 @@ static int init_overlay_changeset(struct
 		if (!fragment->target) {
 			of_node_put(fragment->overlay);
 			ret = -EINVAL;
+			of_node_put(node);
 			goto err_free_fragments;
 		}
 

While reading through the code touched by the patch I noticed that the clean up at label err_free_fragments does not do the required of_node_put() calls. I'll add creating a patch to fix that to my todo list.

-Frank

maintainer Applied
#2 lore raw
In reply to Julia Lawall
Quoted 27 lines · Julia Lawall

From: kernel test robot <[email protected]>

Function "for_each_child_of_node" should have of_node_put() before goto.

Generated by: scripts/coccinelle/iterators/for_each_child.cocci

Fixes 82c2d81361ec ("coccinelle: iterators: Add for_each_child.cocci script")
CC Sumera Priyadarsini <[email protected]>

---

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   812da4d39463a060738008a46cfc9f775e4bfcf6
commit: 82c2d81361ecd142a54e84a9da1e287113314a4f coccinelle: iterators: Add for_each_child.cocci script

:::::: branch date: 13 hours ago
:::::: commit date: 5 months ago

 overlay.c |    1 +
 1 file changed, 1 insertion(+)

drivers/of/overlay.c static int init_overlay_changeset(struct · line 802

Quoted 7 lines
drivers/of/overlay.c +1 -0
@@ -796,6 +796,7 @@ static int init_overlay_changeset(struct
 		if (!fragment->target) {
 			of_node_put(fragment->overlay);
 			ret = -EINVAL;
+			of_node_put(node);
 			goto err_free_fragments;
 		}
 

Applied, thanks!