cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
From: "Brandeburg, Jesse" <jesse.brandeburg@intel.com>
To: Julia Lawall <julia.lawall@inria.fr>
Cc: "cocci@inria.fr" <cocci@inria.fr>,
	"peterz@infradead.org" <peterz@infradead.org>,
	"Kitszel, Przemyslaw" <przemyslaw.kitszel@intel.com>,
	"Brady, Alan" <alan.brady@intel.com>,
	"Keller, Jacob E" <jacob.e.keller@intel.com>
Subject: [cocci] question about kernel cocci and cleanup.h
Date: Thu, 7 Mar 2024 18:25:27 +0000	[thread overview]
Message-ID: <CO1PR11MB49149F1167679926A2917E0997202@CO1PR11MB4914.namprd11.prod.outlook.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 956 bytes --]

Hi Julia and team, I had a question about whether it's possible to use coccinelle/spatch to start to identify functions which are able to use inline destructors (__free or DEFINE_FREE()) from include/linux/cleanup.h

To some extent a missing kfree logic is already part of the scripts/cocci, but what I was curious about is whether spatch can find


  1.  Function that allocates a stack variable which is a pointer (or has one passed as a pointer argument)
  2.  Function calls *alloc
  3.  Function calls kfree() before return in all paths after alloc

There is also a variant of the above cleanup.h macros for functions that acquire a lock but need to release it before returning.

I know this would be nearly impossible to auto-patch, but having a "grep" for this pattern would be super helpful.

Would someone be interested in looking at this for the kernel? It seems like a valuable help to find refactoring locations.

Thoughts?



[-- Attachment #2: Type: text/html, Size: 4976 bytes --]

             reply	other threads:[~2024-03-07 18:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-07 18:25 Brandeburg, Jesse [this message]
2024-03-07 19:12 ` [cocci] question about kernel cocci and cleanup.h Julia Lawall
2024-03-07 20:59 ` Julia Lawall
2024-03-08  7:21   ` Markus Elfring
2024-03-08  6:38 ` Markus Elfring
2024-03-11  9:21 ` Markus Elfring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CO1PR11MB49149F1167679926A2917E0997202@CO1PR11MB4914.namprd11.prod.outlook.com \
    --to=jesse.brandeburg@intel.com \
    --cc=alan.brady@intel.com \
    --cc=cocci@inria.fr \
    --cc=jacob.e.keller@intel.com \
    --cc=julia.lawall@inria.fr \
    --cc=peterz@infradead.org \
    --cc=przemyslaw.kitszel@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).