Coccinelle archive on lore.kernel.org
 help / color / Atom feed
From: Julia Lawall <julia.lawall@lip6.fr>
To: Markus Elfring <Markus.Elfring@web.de>
Cc: Coccinelle <cocci@systeme.lip6.fr>
Subject: Re: [Cocci] Software analysis with SmPL around unchecked function calls
Date: Thu, 10 Oct 2019 15:13:40 +0200 (CEST)
Message-ID: <alpine.DEB.2.21.1910101509370.2305@hadrien> (raw)
In-Reply-To: <24130ec6-4a20-7be4-755f-a6dfffcb6c97@web.de>

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



On Thu, 10 Oct 2019, Markus Elfring wrote:

> Hello,
>
> I would like to try another source code analysis approach out with
> the software combination “Coccinelle 1.0.8-00004-g842075f7”.
>
> @display@
> expression x;
> statement is, es;
> @@
> (
> *x = kmemdup(...);
> |if (...)
> *x = kmemdup(...);
> )
> (if (!x) is
> |if (...) is else es
> |
>  ... when any
>      when != x
> )


It's not clear what you want to match.  The above rule matches all kmemdup
calls that are followed by the the indicated code.  Do you want the
following?

Why not just

x = kmemdup(...);
... when != x

julia

>
>
> This SmPL small script can point an update candidate out like
> the function “imx_pd_bind” as expected.
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/gpu/drm/imx/parallel-display.c?id=43b815c6a8e7dbccb5b8bd9c4b099c24bc22d135#n197
> https://elixir.bootlin.com/linux/v5.4-rc2/source/drivers/gpu/drm/imx/parallel-display.c#L197
>
> Unfortunately, I find also some false positives then at other places.
>
> Example:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/cpufreq/sfi-cpufreq.c?id=8a8c600de5dc1d9a7f4b83269fddc80ebd3dd045#n23
> https://elixir.bootlin.com/linux/v5.4-rc2/source/drivers/cpufreq/sfi-cpufreq.c#L23
>
> …
> @@ -37,7 +37,6 @@ static int sfi_parse_freq(struct sfi_tab
>  	pentry = (struct sfi_freq_table_entry *)sb->pentry;
>  	totallen = num_freq_table_entries * sizeof(*pentry);
>
> -	sfi_cpufreq_array = kmemdup(pentry, totallen, GFP_KERNEL);
>  	if (!sfi_cpufreq_array)
>  		return -ENOMEM;
> …
>
>
> Would you like to clarify this situation for the semantic patch language?
>
> Regards,
> Markus
> _______________________________________________
> Cocci mailing list
> Cocci@systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>

[-- Attachment #2: Type: text/plain, Size: 136 bytes --]

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

  reply index

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-10 12:56 Markus Elfring
2019-10-10 13:13 ` Julia Lawall [this message]
2019-10-10 13:35   ` Markus Elfring
2019-10-10 13:38     ` Julia Lawall
2019-10-10 14:04       ` Markus Elfring
     [not found]         ` <alpine.DEB.2.21.1910101606420.2305@hadrien>
2019-10-10 14:15           ` Markus Elfring
     [not found]             ` <alpine.DEB.2.21.1910102053440.2500@hadrien>
2019-10-11  5:11               ` Markus Elfring
2019-10-11  6:07                 ` Julia Lawall
2019-10-11  7:03                   ` Markus Elfring
     [not found]                     ` <alpine.DEB.2.21.1910110906390.2662@hadrien>
2019-10-11  7:30                       ` Markus Elfring
2019-10-11  9:23                       ` Markus Elfring
2019-10-10 16:25       ` Markus Elfring
2019-10-18 12:54   ` [Cocci] Software analysis with SmPL around unchecked pointer " Markus Elfring
2019-10-18 13:31     ` Julia Lawall
2019-10-18 13:42       ` Markus Elfring
2019-10-18 13:49         ` Julia Lawall
2019-10-18 14:20           ` Markus Elfring
2019-10-18 14:30             ` Julia Lawall
2019-10-18 14:34               ` Markus Elfring
2019-10-18 14:39                 ` Julia Lawall
2019-10-18 14:46                   ` Markus Elfring
2019-10-18 14:52                     ` Julia Lawall
2019-10-18 14:56                       ` Markus Elfring
2019-10-18 16:00       ` Markus Elfring
2019-10-18 16:06         ` Julia Lawall
2019-10-18 16:32           ` Markus Elfring
2019-10-19 15:33         ` Markus Elfring
2019-10-19 15:41           ` Julia Lawall
2019-10-19 16:04             ` Markus Elfring
2019-10-19 19:40             ` Markus Elfring
2019-10-20  5:42               ` Julia Lawall
2019-10-20  6:04                 ` Markus Elfring
2019-10-20  9:22                 ` Markus Elfring

Reply instructions:

You may reply publically 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=alpine.DEB.2.21.1910101509370.2305@hadrien \
    --to=julia.lawall@lip6.fr \
    --cc=Markus.Elfring@web.de \
    --cc=cocci@systeme.lip6.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

Coccinelle archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/cocci/0 cocci/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 cocci cocci/ https://lore.kernel.org/cocci \
		cocci@systeme.lip6.fr
	public-inbox-index cocci

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/fr.lip6.systeme.cocci


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git