From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754387AbZIOOas (ORCPT ); Tue, 15 Sep 2009 10:30:48 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754142AbZIOOam (ORCPT ); Tue, 15 Sep 2009 10:30:42 -0400 Received: from rs1.rw-gmbh.net ([213.239.201.58]:37642 "EHLO rs1.rw-gmbh.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754032AbZIOOam (ORCPT ); Tue, 15 Sep 2009 10:30:42 -0400 X-Greylist: delayed 1717 seconds by postgrey-1.27 at vger.kernel.org; Tue, 15 Sep 2009 10:30:41 EDT Message-ID: <4AAF9E5B.5040909@rw-gmbh.de> Date: Tue, 15 Sep 2009 16:02:03 +0200 From: =?windows-1252?Q?Ralf_R=F6sch?= User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) MIME-Version: 1.0 To: Julia Lawall Cc: Atsushi Nemoto , ralf@linux-mips.org, linux-mips@linux-mips.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH 1/8] arch/mips/txx9: introduce missing kfree, iounmap References: <20090913.232548.253168283.anemo@mba.ocn.ne.jp> <20090914.003321.160496287.anemo@mba.ocn.ne.jp> In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The gpio_remove is missing: arch/mips/txx9/generic/setup.c:838: error: implicit declaration of function ‘gpio_remove’ Should it be gpiochip_remove() instead? -- Ralf Roesch The Julia Lawall schrieb: > From: Julia Lawall > > Error handling code following a kzalloc should free the allocated data. > Error handling code following an ioremap should iounmap the allocated data. > > The semantic match that finds the first problem is as follows: > (http://www.emn.fr/x-info/coccinelle/) > > // > @r exists@ > local idexpression x; > statement S; > expression E; > identifier f,f1,l; > position p1,p2; > expression *ptr != NULL; > @@ > > x@p1 = \(kmalloc\|kzalloc\|kcalloc\)(...); > ... > if (x == NULL) S > <... when != x > when != if (...) { <+...x...+> } > ( > x->f1 = E > | > (x->f1 == NULL || ...) > | > f(...,x->f1,...) > ) > ...> > ( > return \(0\|<+...x...+>\|ptr\); > | > return@p2 ...; > ) > > @script:python@ > p1 << r.p1; > p2 << r.p2; > @@ > > print "* file: %s kmalloc %s return %s" % (p1[0].file,p1[0].line,p2[0].line) > // > > Signed-off-by: Julia Lawall > --- > arch/mips/txx9/generic/setup.c | 17 +++++++++++++---- > 1 files changed, 13 insertions(+), 4 deletions(-) > > diff --git a/arch/mips/txx9/generic/setup.c b/arch/mips/txx9/generic/setup.c > index a205e2b..c860810 100644 > --- a/arch/mips/txx9/generic/setup.c > +++ b/arch/mips/txx9/generic/setup.c > @@ -782,7 +782,7 @@ void __init txx9_iocled_init(unsigned long baseaddr, > return; > iocled->mmioaddr = ioremap(baseaddr, 1); > if (!iocled->mmioaddr) > - return; > + goto out_free; > iocled->chip.get = txx9_iocled_get; > iocled->chip.set = txx9_iocled_set; > iocled->chip.direction_input = txx9_iocled_dir_in; > @@ -791,13 +791,13 @@ void __init txx9_iocled_init(unsigned long baseaddr, > iocled->chip.base = basenum; > iocled->chip.ngpio = num; > if (gpiochip_add(&iocled->chip)) > - return; > + goto out_unmap; > if (basenum < 0) > basenum = iocled->chip.base; > > pdev = platform_device_alloc("leds-gpio", basenum); > if (!pdev) > - return; > + goto out_gpio; > iocled->pdata.num_leds = num; > iocled->pdata.leds = iocled->leds; > for (i = 0; i < num; i++) { > @@ -812,7 +812,16 @@ void __init txx9_iocled_init(unsigned long baseaddr, > } > pdev->dev.platform_data = &iocled->pdata; > if (platform_device_add(pdev)) > - platform_device_put(pdev); > + goto out_pdev; > + return; > +out_pdev: > + platform_device_put(pdev); > +out_gpio: > + gpio_remove(&iocled->chip); > +out_unmap: > + iounmap(iocled->mmioaddr); > +out_free: > + kfree(iocled); > } > #else /* CONFIG_LEDS_GPIO */ > void __init txx9_iocled_init(unsigned long baseaddr, > > From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?windows-1252?Q?Ralf_R=F6sch?= Date: Tue, 15 Sep 2009 14:02:03 +0000 Subject: Re: [PATCH 1/8] arch/mips/txx9: introduce missing kfree, iounmap Message-Id: <4AAF9E5B.5040909@rw-gmbh.de> List-Id: References: <20090913.232548.253168283.anemo@mba.ocn.ne.jp> <20090914.003321.160496287.anemo@mba.ocn.ne.jp> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: quoted-printable To: Julia Lawall Cc: Atsushi Nemoto , ralf@linux-mips.org, linux-mips@linux-mips.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org The gpio_remove is missing: arch/mips/txx9/generic/setup.c:838: error: implicit declaration of functi= on =91gpio_remove=92 Should it be gpiochip_remove() instead? -- Ralf Roesch The Julia Lawall schrieb: > From: Julia Lawall > > Error handling code following a kzalloc should free the allocated data. > Error handling code following an ioremap should iounmap the allocated dat= a. > > The semantic match that finds the first problem is as follows: > (http://www.emn.fr/x-info/coccinelle/) > > // > @r exists@ > local idexpression x; > statement S; > expression E; > identifier f,f1,l; > position p1,p2; > expression *ptr !=3D NULL; > @@ > > x@p1 =3D \(kmalloc\|kzalloc\|kcalloc\)(...); > ... > if (x =3D NULL) S > <... when !=3D x > when !=3D if (...) { <+...x...+> } > ( > x->f1 =3D E > | > (x->f1 =3D NULL || ...) > | > f(...,x->f1,...) > ) > ...> > ( > return \(0\|<+...x...+>\|ptr\); > | > return@p2 ...; > ) > > @script:python@ > p1 << r.p1; > p2 << r.p2; > @@ > > print "* file: %s kmalloc %s return %s" % (p1[0].file,p1[0].line,p2[0].li= ne) > // > > Signed-off-by: Julia Lawall > --- > arch/mips/txx9/generic/setup.c | 17 +++++++++++++---- > 1 files changed, 13 insertions(+), 4 deletions(-) > > diff --git a/arch/mips/txx9/generic/setup.c b/arch/mips/txx9/generic/setu= p.c > index a205e2b..c860810 100644 > --- a/arch/mips/txx9/generic/setup.c > +++ b/arch/mips/txx9/generic/setup.c > @@ -782,7 +782,7 @@ void __init txx9_iocled_init(unsigned long baseaddr, > return; > iocled->mmioaddr =3D ioremap(baseaddr, 1); > if (!iocled->mmioaddr) > - return; > + goto out_free; > iocled->chip.get =3D txx9_iocled_get; > iocled->chip.set =3D txx9_iocled_set; > iocled->chip.direction_input =3D txx9_iocled_dir_in; > @@ -791,13 +791,13 @@ void __init txx9_iocled_init(unsigned long baseaddr, > iocled->chip.base =3D basenum; > iocled->chip.ngpio =3D num; > if (gpiochip_add(&iocled->chip)) > - return; > + goto out_unmap; > if (basenum < 0) > basenum =3D iocled->chip.base; > =20 > pdev =3D platform_device_alloc("leds-gpio", basenum); > if (!pdev) > - return; > + goto out_gpio; > iocled->pdata.num_leds =3D num; > iocled->pdata.leds =3D iocled->leds; > for (i =3D 0; i < num; i++) { > @@ -812,7 +812,16 @@ void __init txx9_iocled_init(unsigned long baseaddr, > } > pdev->dev.platform_data =3D &iocled->pdata; > if (platform_device_add(pdev)) > - platform_device_put(pdev); > + goto out_pdev; > + return; > +out_pdev: > + platform_device_put(pdev); > +out_gpio: > + gpio_remove(&iocled->chip); > +out_unmap: > + iounmap(iocled->mmioaddr); > +out_free: > + kfree(iocled); > } > #else /* CONFIG_LEDS_GPIO */ > void __init txx9_iocled_init(unsigned long baseaddr, > > =20 -- To unsubscribe from this list: send the line "unsubscribe kernel-janitors" = in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html