public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: walter harms <wharms@bfs.de>
Cc: Linus Walleij <linus.walleij@linaro.org>,
	Alexandre Courbot <gnurou@gmail.com>,
	linux-gpio@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch] gpiolib: potential oops on failure path
Date: Fri, 17 Jun 2016 09:59:05 +0000	[thread overview]
Message-ID: <20160617095740.GB32301@mwanda> (raw)
In-Reply-To: <5763C2C1.8000505@bfs.de>

On Fri, Jun 17, 2016 at 11:28:33AM +0200, walter harms wrote:
> >  out_free_descs:
> > +	if (i = GPIOHANDLES_MAX)
> > +		i--;
> >  	for (; i >= 0; i--)
> >  		gpiod_free(lh->descs[i]);
> >  	kfree(lh->label);
> 
> 
> Since we have already noticed that programmes are bad at counting backwards
> is it possible to change the loop into counting up ?
> 
> btw: if lh->descs[i] is initialized to NULL it would be more robust just to free everything like:
> 
> for(i=0;i< GPIOHANDLES_MAX; i++)
>   gpiod_free(lh->descs[i]);
>

Depending on the config gpiod_free(NULL) generates a warning.  It's
possible that it will be generated once with the current code actually
but I didn't feel it was worth worrying about that.

Still I wouldn't want to generate 64 warnings.

regards,
dan carpenter


  reply	other threads:[~2016-06-17  9:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-17  9:15 [patch] gpiolib: potential oops on failure path Dan Carpenter
2016-06-17  9:28 ` walter harms
2016-06-17  9:59   ` Dan Carpenter [this message]
2016-06-18  8:54   ` Linus Walleij
2016-06-18  8:52 ` Linus Walleij
2016-06-18  8:57   ` Linus Walleij

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=20160617095740.GB32301@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=gnurou@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=wharms@bfs.de \
    /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