Coccinelle archive mirror
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: cocci@inria.fr
Subject: [cocci] Determining the statement end according to a pointer dereference (with SmPL)?
Date: Tue, 21 May 2024 17:12:09 +0200	[thread overview]
Message-ID: <550803c2-45e1-4baa-b316-156ccef51390@web.de> (raw)

Hello,

A questionable source code combination can eventually be found also
with a tiny script for the semantic patch language like the following.

Update candidate:
platform/x86: ISST: Support partitioned systems
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c?h=next-20240521&id=9d1d36268f3d8276aefd1fad4e0a415dc8c36edd
https://lkml.org/lkml/2024/4/23/1417

See also:
[PATCH v2] platform/x86: ISST: fix use-after-free in tpmi_sst_dev_remove()
https://lore.kernel.org/lkml/20240517144946.289615-1-harshit.m.mogalapalli@oracle.com/


@usage@
expression context, ex;
identifier member;
@@
*kfree(context);
 ... when != context = ex
     when any
*(context)->member


A succinct search pattern can be easily expressed with an SmPL asterisk for
an involved pointer dereference.
You would probably like to achieve also a corresponding code transformation.
But I find it very challenging so far to determine the end of the statement
which contains the found dereference expression.
I would appreciate your advice.

Regards,
Markus

             reply	other threads:[~2024-05-21 15:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-21 15:12 Markus Elfring [this message]
2024-05-22 13:55 ` [cocci] Analysing statement sequences in consistent ways (with SmPL)? 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=550803c2-45e1-4baa-b316-156ccef51390@web.de \
    --to=markus.elfring@web.de \
    --cc=cocci@inria.fr \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).