Messages in this thread Patch in this message | | | Subject | [PATCH 4/5] Coccinelle: put_device: Extend when constraints for two SmPL ellipses | From | Markus Elfring <> | Date | Mon, 13 May 2019 11:07:14 +0200 |
| |
From: Markus Elfring <elfring@users.sourceforge.net> Date: Mon, 13 May 2019 09:47:17 +0200
A SmPL ellipsis was specified for a search approach so that additional source code would be tolerated between an assignment to a local variable and the corresponding null pointer check.
But such code should be restricted. * The local variable must not be reassigned there. * It must also not be forwarded to an other assignment target.
Take additional casts for these code exclusion specifications into account together with optional parentheses.
Link: https://lore.kernel.org/cocci/201902191014156680299@zte.com.cn/ Link: https://systeme.lip6.fr/pipermail/cocci/2019-February/005620.html Fixes: da9cfb87a44da61f2403c4312916befcb6b6d7e8 ("coccinelle: semantic code search for missing put_device()") Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> --- scripts/coccinelle/free/put_device.cocci | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/scripts/coccinelle/free/put_device.cocci b/scripts/coccinelle/free/put_device.cocci index aae79c02c1e0..28b0be53fb3f 100644 --- a/scripts/coccinelle/free/put_device.cocci +++ b/scripts/coccinelle/free/put_device.cocci @@ -13,13 +13,15 @@ virtual org local idexpression id; expression x,e,e1; position p1,p2; -type T,T1,T2,T3; +type T,T1,T2,T3,T4,T5,T6; @@
id = of_find_device_by_node@p1(x) -... when != e = id + ... when != e = (T4)(id) + when != id = (T5)(e) if (id == NULL || ...) { ... return ...; } ... when != put_device(&id->dev) + when != id = (T6)(e) when != platform_device_put(id) when != of_dev_put(id) when != if (id) { ... put_device(&id->dev) ... } -- 2.21.0
| |