Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753860AbZG0RiF (ORCPT ); Mon, 27 Jul 2009 13:38:05 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753362AbZG0RiE (ORCPT ); Mon, 27 Jul 2009 13:38:04 -0400 Received: from g1t0029.austin.hp.com ([15.216.28.36]:5977 "EHLO g1t0029.austin.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751075AbZG0RiC (ORCPT ); Mon, 27 Jul 2009 13:38:02 -0400 From: Paul Moore Organization: Hewlett-Packard To: Julia Lawall Subject: Re: [PATCH 11/12] net/netlabel: Correct redundant test Date: Mon, 27 Jul 2009 13:37:29 -0400 User-Agent: KMail/1.11.4 (Linux/2.6.30-gentoo-r1; KDE/4.2.4; i686; ; ) Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org References: In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200907271337.30401.paul.moore@hp.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1828 Lines: 70 On Monday 27 July 2009 12:15:43 pm Julia Lawall wrote: > From: Julia Lawall > > 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/) > > // > @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 > ) > // > > Signed-off-by: Julia Lawall Good catch, thanks. Acked-by: Paul Moore > --- > 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/