[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <alpine.DEB.2.22.394.2010131226130.2674@hadrien>
Date: Tue, 13 Oct 2020 12:30:36 +0200 (CEST)
From: Julia Lawall <julia.lawall@...ia.fr>
To: Sumera Priyadarsini <sylphrenadin@...il.com>
cc: cocci@...teme.lip6.fr, michal.lkml@...kovi.net,
nicolas.palix@...g.fr, linux-kernel@...r.kernel.org,
Gilles.Muller@...6.fr
Subject: Re: [Cocci] [PATCH V2] coccinelle: iterators: Add for_each_child.cocci
script
I have one more change to suggest. This one only affects the patch case,
as the other cases just point to a problem but don't ompletely specify
what to do about it.
> +@...eone depends on patch && !context && !org && !report@
> +
> +local idexpression r.n;
> +iterator r.i,i1;
> +expression e;
> +expression list [r.n1] es;
> +statement S;
> +@@
> +
> + i(es,n,...) {
> + ...
> +(
> + of_node_put(n);
> +|
> + e = n
> +|
> + return n;
> +|
> + i1(...,n,...) S
> +|
> ++ of_node_put(n);
> +? return ...;
> +)
> + ... when any
> + }
There is one occurrence of the following code:
for_each_available_child_of_node(search, child) {
name = of_get_property(child, "regulator-compatible", NULL);
if (!name)
name = child->name;
if (!strcmp(desc->of_match, name)) {
of_node_put(search);
return of_node_get(child);
}
}
In this case, the for_each_available_child_of_node has incremented the
reference count of child by 1, and then the return increments it again.
It would be ok to put an of_not_put before the return, which is done by
the above rule, but the code would be even simpler if it would just leave
the reference count as is. So before the current return case, you can put
another return case that does the following:
- return of_node_get(n);
+ return n;
julia
Powered by blists - more mailing lists