All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julia Lawall <julia.lawall@lip6.fr>
To: Markus Elfring <Markus.Elfring@web.de>
Cc: Wen Yang <yellowriver2010@hotmail.com>,
	Gilles Muller <Gilles.Muller@lip6.fr>,
	Nicolas Palix <nicolas.palix@imag.fr>,
	Michal Marek <michal.lkml@markovi.net>,
	Masahiro Yamada <yamada.masahiro@socionext.com>,
	Wen Yang <wen.yang99@zte.com.cn>,
	Cheng Shengyu <cheng.shengyu@zte.com.cn>,
	kernel-janitors@vger.kernel.org,
	LKML <linux-kernel@vger.kernel.org>,
	Coccinelle <cocci@systeme.lip6.fr>
Subject: Re: [PATCH v6] coccinelle: semantic code search for missing put_device()
Date: Sun, 17 Feb 2019 12:37:18 +0100 (CET)	[thread overview]
Message-ID: <alpine.DEB.2.21.1902171235570.2444@hadrien> (raw)
In-Reply-To: <8e7ba7c0-b7fe-a1f0-d28b-0c716ecbcfdb@web.de>



On Sun, 17 Feb 2019, Markus Elfring wrote:

> > +@search exists@
> > +local idexpression id;
> > +expression x,e,e1;
> > +position p1,p2;
> > +type T,T1,T2;
> > +@@
> > +
> > +id = of_find_device_by_node@p1(x)
> > +... when != e = id
>
> I suggest to increase your software development attention also for
> another implementation detail.
> Source code analysis triggers challenges for safe data flow handling.
> the semantic patch language supports search specifications for
> the exclusion of specific assignments.
>
> Does this SmPL code contain a questionable order for the source
> and target metavariables?
> Can the following variant be more appropriate?
>
> + ... when != id = e

This is possible, but I think unlikely.

>
>
> > +if (id == NULL || ...) { ... return ...; }
> > +... when != put_device(&id->dev)
> > +    when != platform_device_put(id)
> > +    when != of_dev_put(id)
> > +    when != if (id) { ... put_device(&id->dev) ... }
> > +    when != e1 = (T)id
>
> Would you like to avoid that the return value from the shown function call
> gets overwritten in the variable before it was used once at least
> (when a bit of extra C code is tolerated before a null pointer check)?

Indeed there should be a put then too, but again, it seems unlikely.

julia


>
> Regards,
> Markus
>

WARNING: multiple messages have this Message-ID (diff)
From: Julia Lawall <julia.lawall@lip6.fr>
To: Markus Elfring <Markus.Elfring@web.de>
Cc: kernel-janitors@vger.kernel.org,
	Michal Marek <michal.lkml@markovi.net>,
	Wen Yang <yellowriver2010@hotmail.com>,
	Nicolas Palix <nicolas.palix@imag.fr>,
	LKML <linux-kernel@vger.kernel.org>,
	Coccinelle <cocci@systeme.lip6.fr>,
	Cheng Shengyu <cheng.shengyu@zte.com.cn>,
	Wen Yang <wen.yang99@zte.com.cn>
Subject: Re: [PATCH v6] coccinelle: semantic code search for missing put_device()
Date: Sun, 17 Feb 2019 11:37:18 +0000	[thread overview]
Message-ID: <alpine.DEB.2.21.1902171235570.2444@hadrien> (raw)
In-Reply-To: <8e7ba7c0-b7fe-a1f0-d28b-0c716ecbcfdb@web.de>



On Sun, 17 Feb 2019, Markus Elfring wrote:

> > +@search exists@
> > +local idexpression id;
> > +expression x,e,e1;
> > +position p1,p2;
> > +type T,T1,T2;
> > +@@
> > +
> > +id = of_find_device_by_node@p1(x)
> > +... when != e = id
>
> I suggest to increase your software development attention also for
> another implementation detail.
> Source code analysis triggers challenges for safe data flow handling.
> the semantic patch language supports search specifications for
> the exclusion of specific assignments.
>
> Does this SmPL code contain a questionable order for the source
> and target metavariables?
> Can the following variant be more appropriate?
>
> + ... when != id = e

This is possible, but I think unlikely.

>
>
> > +if (id = NULL || ...) { ... return ...; }
> > +... when != put_device(&id->dev)
> > +    when != platform_device_put(id)
> > +    when != of_dev_put(id)
> > +    when != if (id) { ... put_device(&id->dev) ... }
> > +    when != e1 = (T)id
>
> Would you like to avoid that the return value from the shown function call
> gets overwritten in the variable before it was used once at least
> (when a bit of extra C code is tolerated before a null pointer check)?

Indeed there should be a put then too, but again, it seems unlikely.

julia


>
> Regards,
> Markus
>

WARNING: multiple messages have this Message-ID (diff)
From: Julia Lawall <julia.lawall@lip6.fr>
To: Markus Elfring <Markus.Elfring@web.de>
Cc: kernel-janitors@vger.kernel.org,
	Michal Marek <michal.lkml@markovi.net>,
	Wen Yang <yellowriver2010@hotmail.com>,
	Nicolas Palix <nicolas.palix@imag.fr>,
	LKML <linux-kernel@vger.kernel.org>,
	Coccinelle <cocci@systeme.lip6.fr>,
	Cheng Shengyu <cheng.shengyu@zte.com.cn>,
	Wen Yang <wen.yang99@zte.com.cn>
Subject: Re: [Cocci] [PATCH v6] coccinelle: semantic code search for missing put_device()
Date: Sun, 17 Feb 2019 12:37:18 +0100 (CET)	[thread overview]
Message-ID: <alpine.DEB.2.21.1902171235570.2444@hadrien> (raw)
In-Reply-To: <8e7ba7c0-b7fe-a1f0-d28b-0c716ecbcfdb@web.de>



On Sun, 17 Feb 2019, Markus Elfring wrote:

> > +@search exists@
> > +local idexpression id;
> > +expression x,e,e1;
> > +position p1,p2;
> > +type T,T1,T2;
> > +@@
> > +
> > +id = of_find_device_by_node@p1(x)
> > +... when != e = id
>
> I suggest to increase your software development attention also for
> another implementation detail.
> Source code analysis triggers challenges for safe data flow handling.
> the semantic patch language supports search specifications for
> the exclusion of specific assignments.
>
> Does this SmPL code contain a questionable order for the source
> and target metavariables?
> Can the following variant be more appropriate?
>
> + ... when != id = e

This is possible, but I think unlikely.

>
>
> > +if (id == NULL || ...) { ... return ...; }
> > +... when != put_device(&id->dev)
> > +    when != platform_device_put(id)
> > +    when != of_dev_put(id)
> > +    when != if (id) { ... put_device(&id->dev) ... }
> > +    when != e1 = (T)id
>
> Would you like to avoid that the return value from the shown function call
> gets overwritten in the variable before it was used once at least
> (when a bit of extra C code is tolerated before a null pointer check)?

Indeed there should be a put then too, but again, it seems unlikely.

julia


>
> Regards,
> Markus
>
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

  reply	other threads:[~2019-02-17 11:37 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-16 16:05 [Cocci] [PATCH v6] coccinelle: semantic code search for missing put_device() Wen Yang
2019-02-16 16:33 ` Julia Lawall
2019-02-16 16:33   ` [Cocci] " Julia Lawall
2019-02-16 18:39 ` [v6] " Markus Elfring
2019-02-16 18:39   ` [Cocci] " Markus Elfring
2019-02-16 18:39   ` Markus Elfring
2019-02-17  2:32   ` [Cocci] 答复: " Wen Yang
2019-02-17  7:42     ` Markus Elfring
2019-02-17  7:42       ` [Cocci] " Markus Elfring
2019-02-17  7:42       ` 答复: [v6] coccinelle: semantic code =?UTF-8?Q?_search_for_missing_p Markus Elfring
2019-02-17  9:50 ` [PATCH v6] coccinelle: semantic code search for missing put_device() Markus Elfring
2019-02-17  9:50   ` [Cocci] " Markus Elfring
2019-02-17  9:50   ` Markus Elfring
2019-02-17 11:37   ` Julia Lawall [this message]
2019-02-17 11:37     ` [Cocci] " Julia Lawall
2019-02-17 11:37     ` Julia Lawall
2019-02-17 11:42     ` Markus Elfring
2019-02-17 11:42       ` [Cocci] " Markus Elfring
2019-02-17 11:42       ` Markus Elfring
2019-02-17 11:48       ` Julia Lawall
2019-02-17 11:48         ` [Cocci] " Julia Lawall
2019-02-17 11:48         ` Julia Lawall
2019-02-17 12:00         ` [v6] " Markus Elfring
2019-02-17 12:00           ` [Cocci] " Markus Elfring
2019-02-17 12:00           ` Markus Elfring
2019-02-17 12:05           ` Julia Lawall
2019-02-17 12:05             ` [Cocci] " Julia Lawall
2019-02-17 12:05             ` Julia Lawall
2019-02-17 12:20             ` Markus Elfring
2019-02-17 12:20               ` [Cocci] " Markus Elfring
2019-02-17 12:20               ` Markus Elfring
2019-02-17 12:52               ` Julia Lawall
2019-02-17 12:52                 ` [Cocci] " Julia Lawall
2019-02-17 12:52                 ` Julia Lawall
2019-02-17 13:14                 ` Markus Elfring
2019-02-17 13:14                   ` [Cocci] " Markus Elfring
2019-02-17 13:14                   ` Markus Elfring
2019-02-18  3:22                   ` [Cocci] " wen.yang99
2019-02-18  6:43                     ` Julia Lawall
2019-02-18  6:43                       ` [Cocci] " Julia Lawall
2019-02-18  6:43                       ` Julia Lawall
2019-02-18  8:19                       ` Markus Elfring
2019-02-18  8:19                         ` [Cocci] " Markus Elfring
2019-02-18  8:19                         ` Markus Elfring
2019-02-19  2:14                         ` [Cocci] " wen.yang99
2019-02-19  7:04                           ` Julia Lawall
2019-02-19  7:04                             ` [Cocci] " Julia Lawall
2019-02-19  7:04                             ` Julia Lawall
2019-02-19  8:12                             ` Markus Elfring
2019-02-19  8:12                               ` [Cocci] " Markus Elfring
2019-02-19  8:12                               ` Markus Elfring
2019-02-19  8:29                           ` Markus Elfring
2019-02-19  8:29                             ` [Cocci] " Markus Elfring
2019-02-19  8:29                             ` Markus Elfring
2019-02-19  9:09                             ` [Cocci] " wen.yang99
2019-02-19  9:30                               ` Markus Elfring
2019-02-19  9:30                                 ` [Cocci] " Markus Elfring
2019-02-19  9:30                                 ` Markus Elfring
2019-03-06 11:18                           ` Markus Elfring
2019-03-06 11:18                             ` [Cocci] " Markus Elfring
2019-03-06 11:18                             ` Markus Elfring
2019-02-18 21:40                     ` Markus Elfring
2019-02-18 21:40                       ` [Cocci] " Markus Elfring
2019-02-18 21:40                       ` 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=alpine.DEB.2.21.1902171235570.2444@hadrien \
    --to=julia.lawall@lip6.fr \
    --cc=Gilles.Muller@lip6.fr \
    --cc=Markus.Elfring@web.de \
    --cc=cheng.shengyu@zte.com.cn \
    --cc=cocci@systeme.lip6.fr \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.lkml@markovi.net \
    --cc=nicolas.palix@imag.fr \
    --cc=wen.yang99@zte.com.cn \
    --cc=yamada.masahiro@socionext.com \
    --cc=yellowriver2010@hotmail.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 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.