public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: walter harms <wharms@bfs.de>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Ashish Jangam <ashish.jangam@kpitcummins.com>,
	Anton Vorontsov <cbou@mail.ru>,
	David Woodhouse <dwmw2@infradead.org>,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch] da9052-battery: don't free IRQ that wasn't requested
Date: Wed, 05 Sep 2012 16:11:01 +0200	[thread overview]
Message-ID: <50475D75.2040908@bfs.de> (raw)
In-Reply-To: <20120905123440.GF6128@elgon.mountain>



Am 05.09.2012 14:34, schrieb Dan Carpenter:
> We should decrement "i" before doing the free_irq().  If we call this
> because request_threaded_irq() failed then we don't want to free the
> thing which failed.  Or in the case where we get here because
> power_supply_register() failed then the original codes does a read past
> the end of the array.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/power/da9052-battery.c b/drivers/power/da9052-battery.c
> index 20b86ed..d9d034d 100644
> --- a/drivers/power/da9052-battery.c
> +++ b/drivers/power/da9052-battery.c
> @@ -623,7 +623,7 @@ static s32 __devinit da9052_bat_probe(struct platform_device *pdev)
>  	return 0;
>  
>  err:
> -	for (; i >= 0; i--) {
> +	while (--i >= 0) {
>  		irq = platform_get_irq_byname(pdev, da9052_bat_irqs[i]);
>  		free_irq(bat->da9052->irq_base + irq, bat);
>  	}

hi da,
(my usual nitpicking ...)
since a lot of people do make mistakes on count-down-loops, is there any chance to
make this a common count-up-for()-loop ?
like:
   for (j=0; j <= i ;j++ ) {
	irq = platform_get_irq_byname(pdev, da9052_bat_irqs[j]);
	free_irq(bat->da9052->irq_base + irq, bat);
	}

re,
 wh

  reply	other threads:[~2012-09-05 14:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-05 12:34 [patch] da9052-battery: don't free IRQ that wasn't requested Dan Carpenter
2012-09-05 14:11 ` walter harms [this message]
2012-09-06 15:07   ` Dan Carpenter
2012-09-20 22:02     ` Anton Vorontsov

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=50475D75.2040908@bfs.de \
    --to=wharms@bfs.de \
    --cc=ashish.jangam@kpitcummins.com \
    --cc=cbou@mail.ru \
    --cc=dan.carpenter@oracle.com \
    --cc=dwmw2@infradead.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@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