Re: [patch] gpiolib: potential oops on failure path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux