Skip to content

Commit 4bb0e6d

Browse files
JuliaLawallmripard
authored andcommitted
drm/sun4i: backend: add missing of_node_puts
The device node iterators perform an of_node_get on each iteration, so a jump out of the loop requires an of_node_put. Remote and port also have augmented reference counts, so drop them on each iteration and at the end of the function, respectively. Remote is only used for the address it contains, not for the contents of that address, so the reference count can be dropped immediately. The semantic patch that fixes the first part of 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_available_child_of_node(root, child) { ... when != of_node_put(child) when != e = child + of_node_put(child); ? break; ... } ... when != child // </smpl> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com> Link: https://patchwork.freedesktop.org/patch/msgid/1547369264-24831-5-git-send-email-Julia.Lawall@lip6.fr
1 parent ce0210c commit 4bb0e6d

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎drivers/gpu/drm/sun4i/sun4i_backend.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -786,17 +786,18 @@ static struct sun4i_frontend *sun4i_backend_find_frontend(struct sun4i_drv *drv,
786786
remote = of_graph_get_remote_port_parent(ep);
787787
if (!remote)
788788
continue;
789+
of_node_put(remote);
789790

790791
/* does this node match any registered engines? */
791792
list_for_each_entry(frontend, &drv->frontend_list, list) {
792793
if (remote == frontend->node) {
793-
of_node_put(remote);
794794
of_node_put(port);
795+
of_node_put(ep);
795796
return frontend;
796797
}
797798
}
798799
}
799-
800+
of_node_put(port);
800801
return ERR_PTR(-EINVAL);
801802
}
802803

0 commit comments

Comments
 (0)