diff mbox series

[11/12] ARM: OMAP2+: add missing of_node_put after of_device_is_available

Message ID 1550928043-14889-12-git-send-email-Julia.Lawall@lip6.fr (mailing list archive)
State New, archived
Headers show
Series add missing of_node_put after of_device_is_available | expand

Commit Message

Julia Lawall Feb. 23, 2019, 1:20 p.m. UTC
Add an of_node_put when a tested device node is not available.

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

// <smpl>
@@
identifier f;
local idexpression e;
expression x;
@@

e = f(...);
... when != of_node_put(e)
    when != x = e
    when != e = x
    when any
if (<+...of_device_is_available(e)...+>) {
  ... when != of_node_put(e)
(
  return e;
|
+ of_node_put(e);
  return ...;
)
}
// </smpl>

Fixes: e0c827aca0730 ("drm/omap: Populate DSS children in omapdss driver")
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 arch/arm/mach-omap2/display.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Tony Lindgren March 22, 2019, 10:24 p.m. UTC | #1
* Julia Lawall <Julia.Lawall@lip6.fr> [190223 13:58]:
> Add an of_node_put when a tested device node is not available.
> 
> The semantic patch that fixes this problem is as follows
> (http://coccinelle.lip6.fr):
> 
> // <smpl>
> @@
> identifier f;
> local idexpression e;
> expression x;
> @@
> 
> e = f(...);
> ... when != of_node_put(e)
>     when != x = e
>     when != e = x
>     when any
> if (<+...of_device_is_available(e)...+>) {
>   ... when != of_node_put(e)
> (
>   return e;
> |
> + of_node_put(e);
>   return ...;
> )
> }
> // </smpl>
> 
> Fixes: e0c827aca0730 ("drm/omap: Populate DSS children in omapdss driver")
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

Thanks applying this one into omap-for-v5.1/fixes.

Regards,

Tony
Markus Elfring April 14, 2019, 4:38 p.m. UTC | #2
> @@ -250,8 +250,10 @@ static int __init omapdss_init_of(void)
>  	if (!node)
>  		return 0;
>
> -	if (!of_device_is_available(node))
> +	if (!of_device_is_available(node)) {
> +		of_node_put(node);
>  		return 0;
> +	}
>
>  	pdev = of_find_device_by_node(node);

Is there a need to put the node also in subsequent if branches
for complete exception handling in this function implementation?

Regards,
Markus
Julia Lawall April 14, 2019, 4:49 p.m. UTC | #3
On Sun, 14 Apr 2019, Markus Elfring wrote:

> > @@ -250,8 +250,10 @@ static int __init omapdss_init_of(void)
> >  	if (!node)
> >  		return 0;
> >
> > -	if (!of_device_is_available(node))
> > +	if (!of_device_is_available(node)) {
> > +		of_node_put(node);
> >  		return 0;
> > +	}
> >
> >  	pdev = of_find_device_by_node(node);
>
> Is there a need to put the node also in subsequent if branches
> for complete exception handling in this function implementation?

Yes, it looks like this is indeed missing.  I will try to send a better
patch when time permits.

julia
diff mbox series

Patch

diff -u -p a/arch/arm/mach-omap2/display.c b/arch/arm/mach-omap2/display.c
--- a/arch/arm/mach-omap2/display.c
+++ b/arch/arm/mach-omap2/display.c
@@ -250,8 +250,10 @@  static int __init omapdss_init_of(void)
 	if (!node)
 		return 0;
 
-	if (!of_device_is_available(node))
+	if (!of_device_is_available(node)) {
+		of_node_put(node);
 		return 0;
+	}
 
 	pdev = of_find_device_by_node(node);