From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753528Ab1HHRro (ORCPT ); Mon, 8 Aug 2011 13:47:44 -0400 Received: from e35.co.us.ibm.com ([32.97.110.153]:59307 "EHLO e35.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752562Ab1HHRrn (ORCPT ); Mon, 8 Aug 2011 13:47:43 -0400 Date: Mon, 8 Aug 2011 10:47:10 -0700 From: Nishanth Aravamudan To: Julia Lawall Cc: Benjamin Herrenschmidt , kernel-janitors@vger.kernel.org, Paul Mackerras , Grant Likely , Milton Miller , Paul Gortmaker , Will Schmidt , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, devicetree-discuss@lists.ozlabs.org Subject: Re: [PATCH 6/9] arch/powerpc/platforms/pseries/iommu.c: add missing kfree Message-ID: <20110808174710.GA3681@us.ibm.com> References: <1312802283-9107-6-git-send-email-julia@diku.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1312802283-9107-6-git-send-email-julia@diku.dk> X-Operating-System: Linux 2.6.38-10-generic (x86_64) User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08.08.2011 [13:18:00 +0200], Julia Lawall wrote: > From: Julia Lawall > > At this point, window has not been stored anywhere, so it has to be freed > before leaving the function. > > A simplified version of the semantic match that finds this problem is as > follows: (http://coccinelle.lip6.fr/) > > // > @exists@ > local idexpression x; > statement S,S1; > expression E; > identifier fl; > expression *ptr != NULL; > @@ > > x = \(kmalloc\|kzalloc\|kcalloc\)(...); > ... > if (x == NULL) S > <... when != x > when != if (...) { <+...kfree(x)...+> } > when any > when != true x == NULL > x->fl > ...> > ( > if (x == NULL) S1 > | > if (...) { ... when != x > when forall > ( > return \(0\|<+...x...+>\|ptr\); > | > * return ...; > ) > } > ) > // > > Signed-off-by: Julia Lawall Acked-by: Nishanth Aravamudan Thanks, Nish -- Nishanth Aravamudan IBM Linux Technology Center