Skip to contentSkip to conversation

coccinelle: fix rules that match outdated function names

PATCH Applied Sang-Heon Jeon 2 participants 14 messages Aug 23 – Aug 30 Coccinelle/Semantic Patches (SmPL)

lore
Share & tools
lore
#0 lore raw

cover coccinelle: fix rules that match outdated function names

Several scripts still list functions that no longer exist in the tree, so those rules can never match.

Patches 1-6 remove those functions from the scripts.

Patch 7 replaces dev_put_track() and dev_hold_track() with netdev_put() and netdev_hold(). I will send separate patches for the two new reports.

Sang-Heon Jeon (7):
coccinelle: remove obsolete pci_free_consistent.cocci
coccinelle: alloc_cast: drop removed allocators
coccinelle: zalloc-simple: drop the kmem_alloc rules
coccinelle: pool_zalloc-simple: drop the pci_pool_alloc rules
coccinelle: kfree_mismatch: drop vmalloc_exec
coccinelle: atomic_as_refcounter: drop atomic_long_dec_and_lock
coccinelle: ifnulldev_put: update outdated helper names

 scripts/coccinelle/api/alloc/alloc_cast.cocci | 20 +++----
 .../api/alloc/pool_zalloc-simple.cocci        | 17 ++----
 .../coccinelle/api/alloc/zalloc-simple.cocci  | 41 +-------------
 .../coccinelle/api/atomic_as_refcounter.cocci |  4 --
 scripts/coccinelle/api/kfree_mismatch.cocci   | 12 ++---
 scripts/coccinelle/free/ifnulldev_put.cocci   |  8 +--
 .../coccinelle/free/pci_free_consistent.cocci | 53 -------------------
 7 files changed, 22 insertions(+), 133 deletions(-)
 delete mode 100644 scripts/coccinelle/free/pci_free_consistent.cocci
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/7 coccinelle: remove obsolete pci_free_consistent.cocci

pci_alloc_consistent() and pci_free_consistent() were removed by commit 7968778914e5 ("PCI: Remove the deprecated "pci-dma-compat.h" API").

So remove the obsolete script.

---
 .../coccinelle/free/pci_free_consistent.cocci | 53 -------------------
 1 file changed, 53 deletions(-)
 delete mode 100644 scripts/coccinelle/free/pci_free_consistent.cocci
scripts/coccinelle/free/pci_free_consistent.cocci deleted +0 -53
deleted file mode 100644
index e062b9ba09ff..000000000000
@@ -1,53 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/// Find missing pci_free_consistent for every pci_alloc_consistent.
-///
-// Confidence: Moderate
-// Copyright: (C) 2013 Petr Strnad.
-// URL: https://coccinelle.gitlabpages.inria.fr/website
-// Keywords: pci_free_consistent, pci_alloc_consistent
-// Options: --no-includes --include-headers
-
-virtual report
-virtual org
-
-@search@
-local idexpression id;
-expression x,y,z,e;
-position p1,p2;
-type T;
-@@
-
-id = pci_alloc_consistent@p1(x,y,&z)
-... when != e = id
-if (id == NULL || ...) { ... return ...; }
-... when != pci_free_consistent(x,y,id,z)
-    when != if (id) { ... pci_free_consistent(x,y,id,z) ... }
-    when != if (y) { ... pci_free_consistent(x,y,id,z) ... }
-    when != e = (T)id
-    when exists
-(
-return 0;
-|
-return 1;
-|
-return id;
-|
-return@p2 ...;
-)
-
-@script:python depends on report@
-p1 << search.p1;
-p2 << search.p2;
-@@
-
-msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on line %s and return without freeing on line %s" % (p1[0].line,p2[0].line)
-coccilib.report.print_report(p2[0],msg)
-
-@script:python depends on org@
-p1 << search.p1;
-p2 << search.p2;
-@@
-
-msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on line %s and return without freeing on line %s" % (p1[0].line,p2[0].line)
-cocci.print_main(msg,p1)
-cocci.print_secs("",p2)
Signature · 1 line
2.43.0
maintainer
#2 lore raw

Re: [PATCH 1/7] coccinelle: remove obsolete pci_free_consistent.cocci

Quoted 2 lines · Sang-Heon Jeon

pci_alloc_consistent() and pci_free_consistent() were removed by commit 7968778914e5 ("PCI: Remove the deprecated "pci-dma-compat.h" API").

Thanks.

There are a lot of other references to these things:

Documentation/scsi/ChangeLog.arcmsr:** 8.replace pci_alloc_consistent()/pci_free_consistent() with kmalloc()/kfree() in arcmsr_iop_message_xfer()
arch/alpha/kernel/pci_iommu.c: DBGA2("pci_free_consistent: [%llx,%zx] from %ps\n",
arch/sparc/kernel/ioport.c: * <zaitcev> Now, driver calls pci_free_consistent(with result of
drivers/net/fddi/defxx.h: char *kmalloced; /* pci_free_consistent this on unload */
drivers/parisc/ccio-dma.c: * This function implements the pci_free_consistent function.
drivers/scsi/3w-xxxx.c: 1.02.00.029 - Add missing pci_free_consistent() in tw_allocate_memory().
sound/pci/asihpi/hpios.h:Need all info for parameters to pci_free_consistent

Documentation/scsi/53c700.rst: used for the pci_alloc_consistent() and pci_map_*() functions.
Documentation/scsi/ChangeLog.arcmsr:** 8.replace pci_alloc_consistent()/pci_free_consistent() with kmalloc()/kfree() in arcmsr_iop_message_xfer()
Documentation/scsi/ChangeLog.megaraid_sas: pci_alloc_consistent replaced by dma_alloc_coherent. With this
Documentation/scsi/ChangeLog.megaraid_sas: > pci_alloc_consistent() just goes and assumes GFP_ATOMIC, whereas
arch/alpha/kernel/pci_iommu.c: printk(KERN_INFO "pci_alloc_consistent: "
arch/alpha/kernel/pci_iommu.c: DBGA2("pci_alloc_consistent: %zx -> [%p,%llx] from %ps\n",

arch/alpha/kernel/pci_iommu.c:   be values that were returned from pci_alloc_consistent.  SIZE must
arch/alpha/kernel/pci_iommu.c:   be the same as what as passed into pci_alloc_consistent.

arch/powerpc/platforms/pseries/iommu.c: * a power of two (due to pci_alloc_consistent requirements).
arch/sparc/kernel/ioport.c: * <rth> zait: as long as pci_alloc_consistent produces something addressable,
drivers/misc/genwqe/card_utils.c: * page_list and pci_alloc_consistent for the sg_list.
drivers/net/wan/wanxl.c: * and pray pci_alloc_consistent() will use this info. It should
drivers/net/wan/wanxl.c: printk(KERN_DEBUG "wanXL %s: pci_alloc_consistent() returned memory"
drivers/parisc/ccio-dma.c:** o SAFE_DMA must be set for "memory" allocated via pci_alloc_consistent().
drivers/parisc/ccio-dma.c:#define HINT_SAFE_DMA 0x02UL /* used for pci_alloc_consistent() pages */
drivers/parisc/ccio-dma.c: * This function implements the pci_alloc_consistent function. sound/pci/asihpi/hpios.h:/** Details of a memory area allocated with pci_alloc_consistent

julia

Quoted 72 lines

So remove the obsolete script.

---
 .../coccinelle/free/pci_free_consistent.cocci | 53 -------------------
 1 file changed, 53 deletions(-)
 delete mode 100644 scripts/coccinelle/free/pci_free_consistent.cocci
scripts/coccinelle/free/pci_free_consistent.cocci deleted +0 -54
deleted file mode 100644
index e062b9ba09ff..000000000000
@@ -1,53 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/// Find missing pci_free_consistent for every pci_alloc_consistent.
-///
-// Confidence: Moderate
-// Copyright: (C) 2013 Petr Strnad.
-// URL: https://coccinelle.gitlabpages.inria.fr/website
-// Keywords: pci_free_consistent, pci_alloc_consistent
-// Options: --no-includes --include-headers
-
-virtual report
-virtual org
-
-@search@
-local idexpression id;
-expression x,y,z,e;
-position p1,p2;
-type T;
-@@
-
-id = pci_alloc_consistent@p1(x,y,&z)
-... when != e = id
-if (id == NULL || ...) { ... return ...; }
-... when != pci_free_consistent(x,y,id,z)
-    when != if (id) { ... pci_free_consistent(x,y,id,z) ... }
-    when != if (y) { ... pci_free_consistent(x,y,id,z) ... }
-    when != e = (T)id
-    when exists
-(
-return 0;
-|
-return 1;
-|
-return id;
-|
-return@p2 ...;
-)
-
-@script:python depends on report@
-p1 << search.p1;
-p2 << search.p2;
-@@
-
-msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on line %s and return without freeing on line %s" % (p1[0].line,p2[0].line)
-coccilib.report.print_report(p2[0],msg)
-
-@script:python depends on org@
-p1 << search.p1;
-p2 << search.p2;
-@@
-
-msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on line %s and return without freeing on line %s" % (p1[0].line,p2[0].line)
-cocci.print_main(msg,p1)
-cocci.print_secs("",p2)
--

2.43.0

#3 lore raw

PATCH 2/7 coccinelle: alloc_cast: drop removed allocators

In reply to Sang-Heon Jeon

- pci_alloc_consistent() and pci_zalloc_consistent() were removed by commit 7968778914e5
("PCI: Remove the deprecated "pci-dma-compat.h" API")

- kmem_alloc() was removed by commit f078d4ea8276
("xfs: convert kmem_alloc() to kmalloc()")

- kmem_zalloc() was removed by commit 10634530f7ba ("xfs: convert kmem_zalloc() to kzalloc()")

- kmem_zone_alloc() and kmem_zone_zalloc() were removed by commit bae633a4a283 ("xfs: remove xfs_zone_{alloc,zalloc} helpers")

So drop them from the rules.

No functional change.

---
 scripts/coccinelle/api/alloc/alloc_cast.cocci | 20 ++++++++-----------
 1 file changed, 8 insertions(+), 12 deletions(-)
scripts/coccinelle/api/alloc/alloc_cast.cocci +8 -12
index 958c914f8ba6..a4b83cc8ea01 100644
@@ -53,9 +53,8 @@ position p != {m1.p1,m2.p2};
   \(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\|
    kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\|vmalloc\|vzalloc\|
    dma_alloc_coherent\|devm_kmalloc\|devm_kzalloc\|
-   kvmalloc\|kvzalloc\|kvmalloc_node\|kvzalloc_node\|pci_alloc_consistent\|
-   pci_zalloc_consistent\|kmem_alloc\|kmem_zalloc\|kmem_zone_alloc\|
-   kmem_zone_zalloc\|vmalloc_node\|vzalloc_node\)(...)
+   kvmalloc\|kvzalloc\|kvmalloc_node\|kvzalloc_node\|
+   vmalloc_node\|vzalloc_node\)(...)
 
 //----------------------------------------------------------
 //  For context mode
@@ -76,9 +75,8 @@ type r1.T;
   \(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\|
    kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\|vmalloc\|vzalloc\|
    dma_alloc_coherent\|devm_kmalloc\|devm_kzalloc\|
-   kvmalloc\|kvzalloc\|kvmalloc_node\|kvzalloc_node\|pci_alloc_consistent\|
-   pci_zalloc_consistent\|kmem_alloc\|kmem_zalloc\|kmem_zone_alloc\|
-   kmem_zone_zalloc\|vmalloc_node\|vzalloc_node\)(...)
+   kvmalloc\|kvzalloc\|kvmalloc_node\|kvzalloc_node\|
+   vmalloc_node\|vzalloc_node\)(...)
 
 //----------------------------------------------------------
 //  For patch mode
@@ -99,9 +97,8 @@ type r1.T;
   \(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\|
    kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\|vmalloc\|vzalloc\|
    dma_alloc_coherent\|devm_kmalloc\|devm_kzalloc\|
-   kvmalloc\|kvzalloc\|kvmalloc_node\|kvzalloc_node\|pci_alloc_consistent\|
-   pci_zalloc_consistent\|kmem_alloc\|kmem_zalloc\|kmem_zone_alloc\|
-   kmem_zone_zalloc\|vmalloc_node\|vzalloc_node\)(...)
+   kvmalloc\|kvzalloc\|kvmalloc_node\|kvzalloc_node\|
+   vmalloc_node\|vzalloc_node\)(...)
 
 //----------------------------------------------------------
 //  For org and report mode
@@ -116,9 +113,8 @@ position p != {m1.p1,m2.p2};
   \(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\|
    kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\|vmalloc\|vzalloc\|
    dma_alloc_coherent\|devm_kmalloc\|devm_kzalloc\|
-   kvmalloc\|kvzalloc\|kvmalloc_node\|kvzalloc_node\|pci_alloc_consistent\|
-   pci_zalloc_consistent\|kmem_alloc\|kmem_zalloc\|kmem_zone_alloc\|
-   kmem_zone_zalloc\|vmalloc_node\|vzalloc_node\)(...)
+   kvmalloc\|kvzalloc\|kvmalloc_node\|kvzalloc_node\|
+   vmalloc_node\|vzalloc_node\)(...)
 
 @script:python depends on org@
 p << r2.p;
Signature · 1 line
2.43.0
maintainer Applied
#4 lore raw

Re: [PATCH 2/7] coccinelle: alloc_cast: drop removed allocators

Quoted 10 lines · Sang-Heon Jeon

- pci_alloc_consistent() and pci_zalloc_consistent() were removed by commit 7968778914e5
("PCI: Remove the deprecated "pci-dma-compat.h" API")

- kmem_alloc() was removed by commit f078d4ea8276
("xfs: convert kmem_alloc() to kmalloc()")

- kmem_zalloc() was removed by commit 10634530f7ba ("xfs: convert kmem_zalloc() to kzalloc()")

Quoted 6 lines

- kmem_zone_alloc() and kmem_zone_zalloc() were removed by commit bae633a4a283 ("xfs: remove xfs_zone_{alloc,zalloc} helpers")

So drop them from the rules.

No functional change.

Applied

Quoted 62 lines
---
 scripts/coccinelle/api/alloc/alloc_cast.cocci | 20 ++++++++-----------
 1 file changed, 8 insertions(+), 12 deletions(-)
scripts/coccinelle/api/alloc/alloc_cast.cocci +8 -13
index 958c914f8ba6..a4b83cc8ea01 100644
@@ -53,9 +53,8 @@ position p != {m1.p1,m2.p2};
   \(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\|
    kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\|vmalloc\|vzalloc\|
    dma_alloc_coherent\|devm_kmalloc\|devm_kzalloc\|
-   kvmalloc\|kvzalloc\|kvmalloc_node\|kvzalloc_node\|pci_alloc_consistent\|
-   pci_zalloc_consistent\|kmem_alloc\|kmem_zalloc\|kmem_zone_alloc\|
-   kmem_zone_zalloc\|vmalloc_node\|vzalloc_node\)(...)
+   kvmalloc\|kvzalloc\|kvmalloc_node\|kvzalloc_node\|
+   vmalloc_node\|vzalloc_node\)(...)
 
 //----------------------------------------------------------
 //  For context mode
@@ -76,9 +75,8 @@ type r1.T;
   \(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\|
    kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\|vmalloc\|vzalloc\|
    dma_alloc_coherent\|devm_kmalloc\|devm_kzalloc\|
-   kvmalloc\|kvzalloc\|kvmalloc_node\|kvzalloc_node\|pci_alloc_consistent\|
-   pci_zalloc_consistent\|kmem_alloc\|kmem_zalloc\|kmem_zone_alloc\|
-   kmem_zone_zalloc\|vmalloc_node\|vzalloc_node\)(...)
+   kvmalloc\|kvzalloc\|kvmalloc_node\|kvzalloc_node\|
+   vmalloc_node\|vzalloc_node\)(...)
 
 //----------------------------------------------------------
 //  For patch mode
@@ -99,9 +97,8 @@ type r1.T;
   \(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\|
    kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\|vmalloc\|vzalloc\|
    dma_alloc_coherent\|devm_kmalloc\|devm_kzalloc\|
-   kvmalloc\|kvzalloc\|kvmalloc_node\|kvzalloc_node\|pci_alloc_consistent\|
-   pci_zalloc_consistent\|kmem_alloc\|kmem_zalloc\|kmem_zone_alloc\|
-   kmem_zone_zalloc\|vmalloc_node\|vzalloc_node\)(...)
+   kvmalloc\|kvzalloc\|kvmalloc_node\|kvzalloc_node\|
+   vmalloc_node\|vzalloc_node\)(...)
 
 //----------------------------------------------------------
 //  For org and report mode
@@ -116,9 +113,8 @@ position p != {m1.p1,m2.p2};
   \(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\|
    kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\|vmalloc\|vzalloc\|
    dma_alloc_coherent\|devm_kmalloc\|devm_kzalloc\|
-   kvmalloc\|kvzalloc\|kvmalloc_node\|kvzalloc_node\|pci_alloc_consistent\|
-   pci_zalloc_consistent\|kmem_alloc\|kmem_zalloc\|kmem_zone_alloc\|
-   kmem_zone_zalloc\|vmalloc_node\|vzalloc_node\)(...)
+   kvmalloc\|kvzalloc\|kvmalloc_node\|kvzalloc_node\|
+   vmalloc_node\|vzalloc_node\)(...)
 
 @script:python depends on org@
 p << r2.p;
--

2.43.0

#5 lore raw

PATCH 3/7 coccinelle: zalloc-simple: drop the kmem_alloc rules

In reply to Sang-Heon Jeon

- kmem_alloc() was removed by commit f078d4ea8276
("xfs: convert kmem_alloc() to kmalloc()")

- kmem_zalloc() was removed by commit 10634530f7ba ("xfs: convert kmem_zalloc() to kzalloc()")

So drop the kmem_alloc rules.

No functional change.

---
 .../coccinelle/api/alloc/zalloc-simple.cocci  | 41 +------------------
 1 file changed, 1 insertion(+), 40 deletions(-)
scripts/coccinelle/api/alloc/zalloc-simple.cocci +1 -40
index d66c45356691..ae1d39e71e31 100644
@@ -35,7 +35,7 @@ statement S;
 @@
 
 * x = (T)\(kmalloc(E1, ...)\|vmalloc(E1)\|dma_alloc_coherent(...,E1,...)\|
-  kmalloc_node(E1, ...)\|kmem_cache_alloc(...)\|kmem_alloc(E1, ...)\|
+  kmalloc_node(E1, ...)\|kmem_cache_alloc(...)\|
   devm_kmalloc(...,E1,...)\|kvmalloc(E1, ...)\|kvmalloc_node(E1,...)\);
   if ((x==NULL) || ...) S
 * memset((T2)x,0,E1);
@@ -88,15 +88,6 @@ statement S;
 - x = (T)kmem_cache_alloc(E3,E4);
 + x = (T)kmem_cache_zalloc(E3,E4);
 |
-- x = kmem_alloc(E1,E2);
-+ x = kmem_zalloc(E1,E2);
-|
-- x = (T *)kmem_alloc(E1,E2);
-+ x = kmem_zalloc(E1,E2);
-|
-- x = (T)kmem_alloc(E1,E2);
-+ x = (T)kmem_zalloc(E1,E2);
-|
 - x = devm_kmalloc(E2,E1,E3);
 + x = devm_kzalloc(E2,E1,E3);
 |
@@ -290,36 +281,6 @@ x << r4.x;
 msg="WARNING: kmem_cache_zalloc should be used for %s, instead of kmem_cache_alloc/memset" % (x)
 coccilib.report.print_report(p[0], msg)
 
-//-----------------------------------------------------------------
-@r5 depends on org || report@
-type T, T2;
-expression x;
-expression E1,E2;
-statement S;
-position p;
-@@
-
- x = (T)kmem_alloc@p(E1,E2);
- if ((x==NULL) || ...) S
- memset((T2)x,0,E1);
-
-@script:python depends on org@
-p << r5.p;
-x << r5.x;
-@@
-
-msg="%s" % (x)
-msg_safe=msg.replace("[","@(").replace("]",")")
-coccilib.org.print_todo(p[0], msg_safe)
-
-@script:python depends on report@
-p << r5.p;
-x << r5.x;
-@@
-
-msg="WARNING: kmem_zalloc should be used for %s, instead of kmem_alloc/memset" % (x)
-coccilib.report.print_report(p[0], msg)
-
 //-----------------------------------------------------------------
 @r6 depends on org || report@
 type T, T2;
Signature · 1 line
2.43.0
maintainer Applied
#6 lore raw

Re: [PATCH 3/7] coccinelle: zalloc-simple: drop the kmem_alloc rules

Quoted 9 lines · Sang-Heon Jeon

- kmem_alloc() was removed by commit f078d4ea8276
("xfs: convert kmem_alloc() to kmalloc()")

- kmem_zalloc() was removed by commit 10634530f7ba ("xfs: convert kmem_zalloc() to kzalloc()")

So drop the kmem_alloc rules.

No functional change.

Applied

Quoted 76 lines
---
 .../coccinelle/api/alloc/zalloc-simple.cocci  | 41 +------------------
 1 file changed, 1 insertion(+), 40 deletions(-)
scripts/coccinelle/api/alloc/zalloc-simple.cocci +1 -41
index d66c45356691..ae1d39e71e31 100644
@@ -35,7 +35,7 @@ statement S;
 @@
 
 * x = (T)\(kmalloc(E1, ...)\|vmalloc(E1)\|dma_alloc_coherent(...,E1,...)\|
-  kmalloc_node(E1, ...)\|kmem_cache_alloc(...)\|kmem_alloc(E1, ...)\|
+  kmalloc_node(E1, ...)\|kmem_cache_alloc(...)\|
   devm_kmalloc(...,E1,...)\|kvmalloc(E1, ...)\|kvmalloc_node(E1,...)\);
   if ((x==NULL) || ...) S
 * memset((T2)x,0,E1);
@@ -88,15 +88,6 @@ statement S;
 - x = (T)kmem_cache_alloc(E3,E4);
 + x = (T)kmem_cache_zalloc(E3,E4);
 |
-- x = kmem_alloc(E1,E2);
-+ x = kmem_zalloc(E1,E2);
-|
-- x = (T *)kmem_alloc(E1,E2);
-+ x = kmem_zalloc(E1,E2);
-|
-- x = (T)kmem_alloc(E1,E2);
-+ x = (T)kmem_zalloc(E1,E2);
-|
 - x = devm_kmalloc(E2,E1,E3);
 + x = devm_kzalloc(E2,E1,E3);
 |
@@ -290,36 +281,6 @@ x << r4.x;
 msg="WARNING: kmem_cache_zalloc should be used for %s, instead of kmem_cache_alloc/memset" % (x)
 coccilib.report.print_report(p[0], msg)
 
-//-----------------------------------------------------------------
-@r5 depends on org || report@
-type T, T2;
-expression x;
-expression E1,E2;
-statement S;
-position p;
-@@
-
- x = (T)kmem_alloc@p(E1,E2);
- if ((x==NULL) || ...) S
- memset((T2)x,0,E1);
-
-@script:python depends on org@
-p << r5.p;
-x << r5.x;
-@@
-
-msg="%s" % (x)
-msg_safe=msg.replace("[","@(").replace("]",")")
-coccilib.org.print_todo(p[0], msg_safe)
-
-@script:python depends on report@
-p << r5.p;
-x << r5.x;
-@@
-
-msg="WARNING: kmem_zalloc should be used for %s, instead of kmem_alloc/memset" % (x)
-coccilib.report.print_report(p[0], msg)
-
 //-----------------------------------------------------------------
 @r6 depends on org || report@
 type T, T2;
--

2.43.0

#7 lore raw

PATCH 4/7 coccinelle: pool_zalloc-simple: drop the pci_pool_alloc rules

In reply to Sang-Heon Jeon

pci_pool_alloc() and pci_pool_zalloc() were removed by commit 88dee3b0efe4 ("PCI: Remove unused pci_pool wrappers").

So drop the pci_pool_alloc rules.

No functional change.

---
 .../api/alloc/pool_zalloc-simple.cocci          | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)
scripts/coccinelle/api/alloc/pool_zalloc-simple.cocci +3 -14
index 9c61a23b34db..2c36fb70e0ab 100644
@@ -5,7 +5,7 @@
 // Copyright: (C) 2015 Intel Corp.
 // Options: --no-includes --include-headers
 //
-// Keywords: dma_pool_zalloc, pci_pool_zalloc
+// Keywords: dma_pool_zalloc
 //
 
 virtual context
@@ -22,7 +22,7 @@ expression x;
 statement S;
 @@
 
-* x = \(dma_pool_alloc\|pci_pool_alloc\)(...);
+* x = dma_pool_alloc(...);
   if ((x==NULL) || ...) S
 * memset(x,0, ...);
 
@@ -41,17 +41,6 @@ statement S;
   if ((x==NULL) || ...) S
 - memset(x,0,...);
 
-@depends on patch@
-expression x;
-expression a,b,c;
-statement S;
-@@
-
-- x = pci_pool_alloc(a,b,c);
-+ x = pci_pool_zalloc(a,b,c);
-  if ((x==NULL) || ...) S
-- memset(x,0,...);
-
 //----------------------------------------------------------
 //  For org and report mode
 //----------------------------------------------------------
@@ -63,7 +52,7 @@ statement S;
 position p;
 @@
 
- x = @p\(dma_pool_alloc\|pci_pool_alloc\)(a,b,c);
+ x = @p\(dma_pool_alloc\)(a,b,c);
  if ((x==NULL) || ...) S
  memset(x,0, ...);
 
Signature · 1 line
2.43.0
maintainer Applied
#8 lore raw

Re: [PATCH 4/7] coccinelle: pool_zalloc-simple: drop the pci_pool_alloc rules

----- Mail original -----

Quoted 6 lines

De: "Sang-Heon Jeon" <[email protected]>
À: "Julia Lawall" <[email protected]>, "nicolas palix" <[email protected]>
Cc: "cocci" <[email protected]>, "linux-kernel" <[email protected]> Envoyé: Dimanche 23 Août 2026 18:18:16
Objet: [PATCH 4/7] coccinelle: pool_zalloc-simple: drop the pci_pool_alloc rules

Quoted 6 lines

pci_pool_alloc() and pci_pool_zalloc() were removed by commit 88dee3b0efe4 ("PCI: Remove unused pci_pool wrappers").

So drop the pci_pool_alloc rules.

No functional change.

Applied. In the last SmPL rule, I removed the \(\) in the + code and move the @p one space to the left, to more obviously attach to the =.

julia

Quoted 57 lines

---
.../api/alloc/pool_zalloc-simple.cocci | 17 +++--------------

1 file changed, 3 insertions(+), 14 deletions(-)
scripts/coccinelle/api/alloc/pool_zalloc-simple.cocci +1 -1
index 9c61a23b34db..2c36fb70e0ab 100644
@@ -5,7 +5,7 @@
 // Copyright: (C) 2015 Intel Corp.
 // Options: --no-includes --include-headers
 //
-// Keywords: dma_pool_zalloc, pci_pool_zalloc
+// Keywords: dma_pool_zalloc
 //
 

virtual context

scripts/coccinelle/api/alloc/pool_zalloc-simple.cocci +0 -0
@@ -22,7 +22,7 @@ expression x;
 statement S;

@@

scripts/coccinelle/api/alloc/pool_zalloc-simple.cocci +1 -1
-* x = \(dma_pool_alloc\|pci_pool_alloc\)(...);
+* x = dma_pool_alloc(...);
  if ((x==NULL) || ...) S

* memset(x,0, ...);

scripts/coccinelle/api/alloc/pool_zalloc-simple.cocci +0 -12
@@ -41,17 +41,6 @@ statement S;
  if ((x==NULL) || ...) S
- memset(x,0,...);
 
-@depends on patch@
-expression x;
-expression a,b,c;
-statement S;
-@@
-
-- x = pci_pool_alloc(a,b,c);
-+ x = pci_pool_zalloc(a,b,c);
-  if ((x==NULL) || ...) S
-- memset(x,0,...);
-
 //----------------------------------------------------------
 //  For org and report mode
 //----------------------------------------------------------
@@ -63,7 +52,7 @@ statement S;
 position p;

@@

- x = @p\(dma_pool_alloc\|pci_pool_alloc\)(a,b,c);
+ x = @p\(dma_pool_alloc\)(a,b,c);
if ((x==NULL) || ...) S
memset(x,0, ...);

--
2.43.0

#9 lore raw

PATCH 5/7 coccinelle: kfree_mismatch: drop vmalloc_exec

In reply to Sang-Heon Jeon

vmalloc_exec() was removed by commit 7a0e27b2a0ce ("mm: remove vmalloc_exec").

So drop it from the rules.

No functional change.

---
 scripts/coccinelle/api/kfree_mismatch.cocci | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
scripts/coccinelle/api/kfree_mismatch.cocci +6 -6
index d46a9b3eb7b3..bc90d0c071ac 100644
@@ -29,7 +29,7 @@ position kok, vok;
   } else {
     ...
     E = \(vmalloc\|vzalloc\|vmalloc_user\|vmalloc_node\|
-          vzalloc_node\|vmalloc_exec\|vmalloc_32\|
+          vzalloc_node\|vmalloc_32\|
           vmalloc_32_user\|__vmalloc\|__vmalloc_node_range\|
           __vmalloc_node\)(...)@vok
     ...
@@ -42,7 +42,7 @@ position kok, vok;
   if (E == NULL) {
     ...
     E = \(vmalloc\|vzalloc\|vmalloc_user\|vmalloc_node\|
-          vzalloc_node\|vmalloc_exec\|vmalloc_32\|
+          vzalloc_node\|vmalloc_32\|
           vmalloc_32_user\|__vmalloc\|__vmalloc_node_range\|
           __vmalloc_node\)(...)@vok
     ...
@@ -68,7 +68,7 @@ position f != free.fok;
 * E = \(kmalloc\|kzalloc\|krealloc\|kcalloc\|kmalloc_node\|
 *       kzalloc_node\|kmalloc_array\|kmalloc_array_node\|
 *       kcalloc_node\)(...)@a
-  ... when != if (...) { ... E = \(vmalloc\|vzalloc\|vmalloc_user\|vmalloc_node\|vzalloc_node\|vmalloc_exec\|vmalloc_32\|vmalloc_32_user\|__vmalloc\|__vmalloc_node_range\|__vmalloc_node\)(...); ... }
+  ... when != if (...) { ... E = \(vmalloc\|vzalloc\|vmalloc_user\|vmalloc_node\|vzalloc_node\|vmalloc_32\|vmalloc_32_user\|__vmalloc\|__vmalloc_node_range\|__vmalloc_node\)(...); ... }
       when != is_vmalloc_addr(E)
       when any
 * \(vfree\|vfree_atomic\|kvfree\)(E)@f
@@ -82,7 +82,7 @@ position f != free.fok;
   E = \(kmalloc\|kzalloc\|krealloc\|kcalloc\|kmalloc_node\|
         kzalloc_node\|kmalloc_array\|kmalloc_array_node\|
         kcalloc_node\)(...)@a
-  ... when != if (...) { ... E = \(vmalloc\|vzalloc\|vmalloc_user\|vmalloc_node\|vzalloc_node\|vmalloc_exec\|vmalloc_32\|vmalloc_32_user\|__vmalloc\|__vmalloc_node_range\|__vmalloc_node\)(...); ... }
+  ... when != if (...) { ... E = \(vmalloc\|vzalloc\|vmalloc_user\|vmalloc_node\|vzalloc_node\|vmalloc_32\|vmalloc_32_user\|__vmalloc\|__vmalloc_node_range\|__vmalloc_node\)(...); ... }
       when != is_vmalloc_addr(E)
       when any
 - \(vfree\|vfree_atomic\|kvfree\)(E)@f
@@ -95,7 +95,7 @@ position f != free.fok;
 @@
 
 * E = \(vmalloc\|vzalloc\|vmalloc_user\|vmalloc_node\|vzalloc_node\|
-*       vmalloc_exec\|vmalloc_32\|vmalloc_32_user\|__vmalloc\|
+*       vmalloc_32\|vmalloc_32_user\|__vmalloc\|
 *       __vmalloc_node_range\|__vmalloc_node\)(...)@a
   ... when != is_vmalloc_addr(E)
       when any
@@ -108,7 +108,7 @@ position f != free.fok;
 @@
 
   E = \(vmalloc\|vzalloc\|vmalloc_user\|vmalloc_node\|vzalloc_node\|
-        vmalloc_exec\|vmalloc_32\|vmalloc_32_user\|__vmalloc\|
+        vmalloc_32\|vmalloc_32_user\|__vmalloc\|
         __vmalloc_node_range\|__vmalloc_node\)(...)@a
   ... when != is_vmalloc_addr(E)
       when any
Signature · 1 line
2.43.0
maintainer Applied
#10 lore raw

Re: [PATCH 5/7] coccinelle: kfree_mismatch: drop vmalloc_exec

Quoted 6 lines · Sang-Heon Jeon

vmalloc_exec() was removed by commit 7a0e27b2a0ce ("mm: remove vmalloc_exec").

So drop it from the rules.

No functional change.

Applied.

Quoted 68 lines
---
 scripts/coccinelle/api/kfree_mismatch.cocci | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
scripts/coccinelle/api/kfree_mismatch.cocci +6 -7
index d46a9b3eb7b3..bc90d0c071ac 100644
@@ -29,7 +29,7 @@ position kok, vok;
   } else {
...
     E = \(vmalloc\|vzalloc\|vmalloc_user\|vmalloc_node\|
-          vzalloc_node\|vmalloc_exec\|vmalloc_32\|
+          vzalloc_node\|vmalloc_32\|
           vmalloc_32_user\|__vmalloc\|__vmalloc_node_range\|
           __vmalloc_node\)(...)@vok
...
@@ -42,7 +42,7 @@ position kok, vok;
   if (E == NULL) {
...
     E = \(vmalloc\|vzalloc\|vmalloc_user\|vmalloc_node\|
-          vzalloc_node\|vmalloc_exec\|vmalloc_32\|
+          vzalloc_node\|vmalloc_32\|
           vmalloc_32_user\|__vmalloc\|__vmalloc_node_range\|
           __vmalloc_node\)(...)@vok
...
@@ -68,7 +68,7 @@ position f != free.fok;
 * E = \(kmalloc\|kzalloc\|krealloc\|kcalloc\|kmalloc_node\|
 *       kzalloc_node\|kmalloc_array\|kmalloc_array_node\|
 *       kcalloc_node\)(...)@a
-  ... when != if (...) { ... E = \(vmalloc\|vzalloc\|vmalloc_user\|vmalloc_node\|vzalloc_node\|vmalloc_exec\|vmalloc_32\|vmalloc_32_user\|__vmalloc\|__vmalloc_node_range\|__vmalloc_node\)(...); ... }
+  ... when != if (...) { ... E = \(vmalloc\|vzalloc\|vmalloc_user\|vmalloc_node\|vzalloc_node\|vmalloc_32\|vmalloc_32_user\|__vmalloc\|__vmalloc_node_range\|__vmalloc_node\)(...); ... }
       when != is_vmalloc_addr(E)
       when any
 * \(vfree\|vfree_atomic\|kvfree\)(E)@f
@@ -82,7 +82,7 @@ position f != free.fok;
   E = \(kmalloc\|kzalloc\|krealloc\|kcalloc\|kmalloc_node\|
         kzalloc_node\|kmalloc_array\|kmalloc_array_node\|
         kcalloc_node\)(...)@a
-  ... when != if (...) { ... E = \(vmalloc\|vzalloc\|vmalloc_user\|vmalloc_node\|vzalloc_node\|vmalloc_exec\|vmalloc_32\|vmalloc_32_user\|__vmalloc\|__vmalloc_node_range\|__vmalloc_node\)(...); ... }
+  ... when != if (...) { ... E = \(vmalloc\|vzalloc\|vmalloc_user\|vmalloc_node\|vzalloc_node\|vmalloc_32\|vmalloc_32_user\|__vmalloc\|__vmalloc_node_range\|__vmalloc_node\)(...); ... }
       when != is_vmalloc_addr(E)
       when any
 - \(vfree\|vfree_atomic\|kvfree\)(E)@f
@@ -95,7 +95,7 @@ position f != free.fok;
 @@
 
 * E = \(vmalloc\|vzalloc\|vmalloc_user\|vmalloc_node\|vzalloc_node\|
-*       vmalloc_exec\|vmalloc_32\|vmalloc_32_user\|__vmalloc\|
+*       vmalloc_32\|vmalloc_32_user\|__vmalloc\|
 *       __vmalloc_node_range\|__vmalloc_node\)(...)@a
   ... when != is_vmalloc_addr(E)
       when any
@@ -108,7 +108,7 @@ position f != free.fok;
 @@
 
   E = \(vmalloc\|vzalloc\|vmalloc_user\|vmalloc_node\|vzalloc_node\|
-        vmalloc_exec\|vmalloc_32\|vmalloc_32_user\|__vmalloc\|
+        vmalloc_32\|vmalloc_32_user\|__vmalloc\|
         __vmalloc_node_range\|__vmalloc_node\)(...)@a
   ... when != is_vmalloc_addr(E)
       when any
--

2.43.0

#11 lore raw

PATCH 6/7 coccinelle: atomic_as_refcounter: drop atomic_long_dec_and_lock

In reply to Sang-Heon Jeon

atomic_long_dec_and_lock() has never existed. So drop it from the rules.

No functional change.

---
 scripts/coccinelle/api/atomic_as_refcounter.cocci | 4 ----
 1 file changed, 4 deletions(-)
scripts/coccinelle/api/atomic_as_refcounter.cocci +0 -4
index bbe5b2932933..af82b9e094aa 100644
@@ -26,8 +26,6 @@ identifier fname6 =~ ".*call_rcu.*";
  atomic_dec_and_test@p1(&(a)->x)
 |
  atomic_dec_and_lock@p1(&(a)->x, ...)
-|
- atomic_long_dec_and_lock@p1(&(a)->x, ...)
 |
  atomic_long_dec_and_test@p1(&(a)->x)
 |
@@ -69,8 +67,6 @@ identifier fname =~ ".*free.*";
  atomic_dec_and_test@p1(&(a)->x)
 |
  atomic_dec_and_lock@p1(&(a)->x, ...)
-|
- atomic_long_dec_and_lock@p1(&(a)->x, ...)
 |
  atomic_long_dec_and_test@p1(&(a)->x)
 |
Signature · 1 line
2.43.0
maintainer Applied
#12 lore raw

Re: [PATCH 6/7] coccinelle: atomic_as_refcounter: drop atomic_long_dec_and_lock

Quoted 3 lines · Sang-Heon Jeon

atomic_long_dec_and_lock() has never existed. So drop it from the rules.

No functional change.

Applied

Quoted 32 lines
---
 scripts/coccinelle/api/atomic_as_refcounter.cocci | 4 ----
 1 file changed, 4 deletions(-)
scripts/coccinelle/api/atomic_as_refcounter.cocci +0 -5
index bbe5b2932933..af82b9e094aa 100644
@@ -26,8 +26,6 @@ identifier fname6 =~ ".*call_rcu.*";
  atomic_dec_and_test@p1(&(a)->x)
 |
  atomic_dec_and_lock@p1(&(a)->x, ...)
-|
- atomic_long_dec_and_lock@p1(&(a)->x, ...)
 |
  atomic_long_dec_and_test@p1(&(a)->x)
 |
@@ -69,8 +67,6 @@ identifier fname =~ ".*free.*";
  atomic_dec_and_test@p1(&(a)->x)
 |
  atomic_dec_and_lock@p1(&(a)->x, ...)
-|
- atomic_long_dec_and_lock@p1(&(a)->x, ...)
 |
  atomic_long_dec_and_test@p1(&(a)->x)
 |
--

2.43.0

#13 lore raw

PATCH 7/7 coccinelle: ifnulldev_put: update outdated helper names

In reply to Sang-Heon Jeon

dev_put_track() and dev_hold_track() were renamed to netdev_put() and netdev_hold() by commit d62607c3fe45 ("net: rename reference+tracking helpers").

So update the names.

---
 scripts/coccinelle/free/ifnulldev_put.cocci | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
scripts/coccinelle/free/ifnulldev_put.cocci +4 -4
index 2bd2e8fae485..adb08252f98d 100644
@@ -23,13 +23,13 @@ expression E;
 |
   dev_put(E);
 |
-  dev_put_track(E, ...);
+  netdev_put(E, ...);
 |
   __dev_hold(E);
 |
   dev_hold(E);
 |
-  dev_hold_track(E, ...);
+  netdev_hold(E, ...);
 )
 
 @r depends on context || report || org @
@@ -38,8 +38,8 @@ position p;
 @@
 
 * if (E != NULL)
-*	\(__dev_put@p\|dev_put@p\|dev_put_track@p\|__dev_hold@p\|dev_hold@p\|
-*         dev_hold_track@p\)(E, ...);
+*	\(__dev_put@p\|dev_put@p\|netdev_put@p\|__dev_hold@p\|dev_hold@p\|
+*         netdev_hold@p\)(E, ...);
 
 @script:python depends on org@
 p << r.p;
Signature · 1 line
2.43.0