netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paul Moore <paul.moore@hp.com>
To: Julia Lawall <julia@diku.dk>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 11/12] net/netlabel: Correct redundant test
Date: Mon, 27 Jul 2009 13:37:29 -0400	[thread overview]
Message-ID: <200907271337.30401.paul.moore@hp.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0907271815260.2682@ask.diku.dk>

On Monday 27 July 2009 12:15:43 pm Julia Lawall wrote:
> From: Julia Lawall <julia@diku.dk>
>
> entry was tested for NULL near the beginning of the function, followed by a
> return, and there is no intervening modification of its value.
>
> A simplified version of the semantic match that finds this problem is as
> follows: (http://www.emn.fr/x-info/coccinelle/)
>
> // <smpl>
> @r exists@
> local idexpression x;
> expression E;
> position p1,p2;
> @@
>
> if (x == NULL || ...) { ... when forall
>    return ...; }
> ... when != \(x=E\|x--\|x++\|--x\|++x\|x-=E\|x+=E\|x|=E\|x&=E\|&x\)
> (
> *x == NULL
>
> *x != NULL
> )
> // </smpl>
>
> Signed-off-by: Julia Lawall <julia@diku.dk>

Good catch, thanks.

Acked-by: Paul Moore <paul.moore@hp.com>

> ---
>  net/netlabel/netlabel_kapi.c        |    6 ++----
>  1 files changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/net/netlabel/netlabel_kapi.c b/net/netlabel/netlabel_kapi.c
> index b0e582f..3ff6f32 100644
> --- a/net/netlabel/netlabel_kapi.c
> +++ b/net/netlabel/netlabel_kapi.c
> @@ -185,8 +185,7 @@ int netlbl_cfg_unlbl_map_add(const char *domain,
>  	return 0;
>
>  cfg_unlbl_map_add_failure:
> -	if (entry != NULL)
> -		kfree(entry->domain);
> +	kfree(entry->domain);
>  	kfree(entry);
>  	kfree(addrmap);
>  	kfree(map4);
> @@ -385,8 +384,7 @@ int netlbl_cfg_cipsov4_map_add(u32 doi,
>
>  cfg_cipsov4_map_add_failure:
>  	cipso_v4_doi_putdef(doi_def);
> -	if (entry != NULL)
> -		kfree(entry->domain);
> +	kfree(entry->domain);
>  	kfree(entry);
>  	kfree(addrmap);
>  	kfree(addrinfo);

-- 
paul moore
linux @ hp


  reply	other threads:[~2009-07-27 17:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-27 16:15 [PATCH 11/12] net/netlabel: Correct redundant test Julia Lawall
2009-07-27 17:37 ` Paul Moore [this message]
2009-07-27 18:36   ` David Miller

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=200907271337.30401.paul.moore@hp.com \
    --to=paul.moore@hp.com \
    --cc=julia@diku.dk \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /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).