[PATCH] cocinelle: iterators: optimize device_node_continue rule

From: Ziyang Xuan
Date: Tue Apr 19 2022 - 07:52:27 EST


Execute the device_node_continue.cocci for kernel source. Get an error
report as following:
./drivers/pci/hotplug/pnv_php.c:161:2-13: ERROR: probable double put.

After analysis, we can find that it is false positive, because it is to
detach the node from device tree. And we can abstract out an exception.

Signed-off-by: Ziyang Xuan <william.xuanziyang@xxxxxxxxxx>
---
scripts/coccinelle/iterators/device_node_continue.cocci | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/scripts/coccinelle/iterators/device_node_continue.cocci b/scripts/coccinelle/iterators/device_node_continue.cocci
index f8cd14dfa604..4b8ee3316a8c 100644
--- a/scripts/coccinelle/iterators/device_node_continue.cocci
+++ b/scripts/coccinelle/iterators/device_node_continue.cocci
@@ -49,9 +49,11 @@ for_each_node_with_property(n,e1) S
&
i@p1(...) {
... when != of_node_get(n)
+ when != of_detach_node(n)
when any
of_node_put@p2(n);
- ... when any
+ ... when != of_detach_node(n)
+ when any
}
)

--
2.25.1