Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754587Ab1CQPHP (ORCPT ); Thu, 17 Mar 2011 11:07:15 -0400 Received: from mail-iw0-f174.google.com ([209.85.214.174]:62041 "EHLO mail-iw0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751900Ab1CQPHL (ORCPT ); Thu, 17 Mar 2011 11:07:11 -0400 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=ws57jJHgXo9p+oM8ZWpc0oXBjO6oL8ryqNwbw0PyfjdrCTOmZJOXk8IVGSp0hjocZq 0d50y6DLJhjlAPCdw/7hTdsFBLyutAQK2nvZ8gNih6CnmaicA24F3cctG9rHUVvEDF7V /PIgR6oSG1Zmz6JhclR/MBpBzedOR0xXaceFA= MIME-Version: 1.0 In-Reply-To: <1299477371.10486.2.camel@mola> References: <1299477315.10486.1.camel@mola> <1299477371.10486.2.camel@mola> From: Eric Miao Date: Thu, 17 Mar 2011 23:06:51 +0800 Message-ID: Subject: Re: [PATCH 2/2] [ARM] am300epd: fix resource leak in am300_init_gpio_regs error path To: Axel Lin Cc: linux-kernel@vger.kernel.org, Jaya Kumar , Russell King , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id p2HF7L8M010324 Content-Length: 1776 Lines: 50 Applied. On Mon, Mar 7, 2011 at 1:56 PM, Axel Lin wrote: > If gpio_request fails when i > 0, gpios[0] is not freed in current > implementation. > > Signed-off-by: Axel Lin > --- >  arch/arm/mach-pxa/am300epd.c |   13 +++++++------ >  1 files changed, 7 insertions(+), 6 deletions(-) > > diff --git a/arch/arm/mach-pxa/am300epd.c b/arch/arm/mach-pxa/am300epd.c > index 993d75e..fa8bad2 100644 > --- a/arch/arm/mach-pxa/am300epd.c > +++ b/arch/arm/mach-pxa/am300epd.c > @@ -125,10 +125,7 @@ static int am300_init_gpio_regs(struct broadsheetfb_par *par) >                if (err) { >                        dev_err(&am300_device->dev, "failed requesting " >                                "gpio %d, err=%d\n", i, err); > -                       while (i >= DB0_GPIO_PIN) > -                               gpio_free(i--); > -                       i = ARRAY_SIZE(gpios) - 1; > -                       goto err_req_gpio; > +                       goto err_req_gpio2; >                } >        } > > @@ -159,9 +156,13 @@ static int am300_init_gpio_regs(struct broadsheetfb_par *par) > >        return 0; > > +err_req_gpio2: > +       while (--i >= DB0_GPIO_PIN) > +               gpio_free(i); > +       i = ARRAY_SIZE(gpios); >  err_req_gpio: > -       while (i > 0) > -               gpio_free(gpios[i--]); > +       while (--i >= 0) > +               gpio_free(gpios[i]); > >        return err; >  } > -- > 1.7.2 > > > > ????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?