Coccinelle: kmerr: increase check list

Message ID 20230530074044.1603426-1-claudiu.beznea@microchip.com
State New
Headers
Series Coccinelle: kmerr: increase check list |

Commit Message

Claudiu Beznea May 30, 2023, 7:40 a.m. UTC
  There are other functions allocating memory who's return value could
be NULL in case allocation fails. Update the list with these.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
---
 scripts/coccinelle/null/kmerr.cocci | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Julia Lawall May 30, 2023, 12:26 p.m. UTC | #1
On Tue, 30 May 2023, Markus Elfring wrote:

> …
> > +++ b/scripts/coccinelle/null/kmerr.cocci
> …
> > @@ -51,7 +51,7 @@ position any withtest.p;
> >  identifier f;
> >  @@
> >
> > -x@p1 = \(kmalloc\|kzalloc\|kcalloc\)(...);
> > +x@p1 = \(kmalloc\|devm_kmalloc\|kmalloc_array\|devm_kmalloc_array\|krealloc_array\|kzalloc\|devm_kzalloc\|kcalloc\|devm_kcalloc\|kasprintf\|devm_kasprintf\|kstrdup\|kstrdup_const\)(...);
> >  ...
> >  x1@p = f@p2(...);
> >  if (!x1) S
>
> Can it be nicer to specify desired function names on multiple lines
> for such a SmPL disjunction?
>
> Would you sort them according to their call probability?

Please don't follow either of these suggestions.

julia
  

Patch

diff --git a/scripts/coccinelle/null/kmerr.cocci b/scripts/coccinelle/null/kmerr.cocci
index 68db20de62eb..db1387f1938a 100644
--- a/scripts/coccinelle/null/kmerr.cocci
+++ b/scripts/coccinelle/null/kmerr.cocci
@@ -35,7 +35,7 @@  position any withtest.p;
 identifier f;
 @@
 
-*x@p1 = \(kmalloc\|kzalloc\|kcalloc\)(...);
+*x@p1 = \(kmalloc\|devm_kmalloc\|kmalloc_array\|devm_kmalloc_array\|krealloc_array\|kzalloc\|devm_kzalloc\|kcalloc\|devm_kcalloc\|kasprintf\|devm_kasprintf\|kstrdup\|kstrdup_const\)(...);
 ...
 *x1@p = f(...);
 if (!x1) S
@@ -51,7 +51,7 @@  position any withtest.p;
 identifier f;
 @@
 
-x@p1 = \(kmalloc\|kzalloc\|kcalloc\)(...);
+x@p1 = \(kmalloc\|devm_kmalloc\|kmalloc_array\|devm_kmalloc_array\|krealloc_array\|kzalloc\|devm_kzalloc\|kcalloc\|devm_kcalloc\|kasprintf\|devm_kasprintf\|kstrdup\|kstrdup_const\)(...);
 ...
 x1@p = f@p2(...);
 if (!x1) S