All of lore.kernel.org
 help / color / mirror / Atom feed
* [cocci] __free() attribute inhibits matching?
@ 2025-03-17 18:44 Kees Cook
  2025-03-17 20:59 ` Julia Lawall
  2025-03-18 17:43 ` Markus Elfring
  0 siblings, 2 replies; 21+ messages in thread
From: Kees Cook @ 2025-03-17 18:44 UTC (permalink / raw)
  To: Julia Lawall; +Cc: cocci@inria.fr

Hi!

It seems that the mere presence of the "__free" attribute breaks
matching:

$ cat test.c
static void why(void)
{
        u64 *rates_64 __free(kfree) = NULL;
        rates_64 = kcalloc(count, sizeof(*rates_64), GFP_KERNEL);
}

$ cat match.cocci
@replace@
expression THING, COUNT;
expression GFP;
@@

-       kcalloc(COUNT, sizeof(*THING), GFP)
+       kzalloc_objs(*THING, COUNT, GFP)


$ spatch --very-quiet --cocci-file match.cocci test.c


Which doesn't match. If I comment out the "__free()" it works:

$ cat test.c
static void why(void)
{
        u64 *rates_64 /*__free(kfree)*/ = NULL;
        rates_64 = kcalloc(count, sizeof(*rates_64), GFP_KERNEL);
}

$ spatch --very-quiet --cocci-file match.cocci test.c
--- test.c
+++ cocci-output-1466652-b8a5c5-test.c
@@ -1,5 +1,5 @@
 static void why(void)
 {
        u64 *rates_64 /*__free(kfree)*/ = NULL;
-       rates_64 = kcalloc(count, sizeof(*rates_64), GFP_KERNEL);
+       rates_64 = kzalloc_objs(*rates_64, count, GFP_KERNEL);
 }


I have tried adding "attribute name __free;" to the rule (which didn't
seem sane, but also didn't work). I have tried adding this line to my
standard.h:
#define __free(x) MACROANNOTATION
but that didn't work either.

What is going wrong here?

Thanks!

-Kees

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2025-03-21 13:52 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-17 18:44 [cocci] __free() attribute inhibits matching? Kees Cook
2025-03-17 20:59 ` Julia Lawall
2025-03-17 23:02   ` Kees Cook
2025-03-17 23:13     ` Julia Lawall
2025-03-18 15:39       ` Kees Cook
2025-03-18 15:43         ` Julia Lawall
2025-03-18 16:30           ` Kees Cook
2025-03-18 17:56             ` Julia Lawall
2025-03-19  3:31               ` Kees Cook
2025-03-19  5:55                 ` Julia Lawall
2025-03-19  7:20                   ` [cocci] Checking the determination of type information? Markus Elfring
2025-03-19  7:44                 ` [cocci] __free() attribute inhibits matching? Julia Lawall
2025-03-19 20:06                   ` Kees Cook
2025-03-19 21:30                   ` Kees Cook
2025-03-19 23:25                     ` Julia Lawall
2025-03-21 13:52                     ` Markus Elfring
2025-03-19 10:24                 ` Markus Elfring
2025-03-19 10:57                 ` Markus Elfring
2025-03-18 17:43 ` Markus Elfring
2025-03-18 18:02   ` Kees Cook
2025-03-18 19:18     ` Markus Elfring

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.