[lvc-project] [PATCH] gpio: davinci: Fix potential buffer overflow

Dan Carpenter dan.carpenter at linaro.org
Thu Mar 28 19:45:03 MSK 2024


On Thu, Mar 28, 2024 at 04:27:24PM +0100, Alexander Lobakin wrote:
> > diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c
> > index bb499e362912..b65df1f2b83f 100644
> > --- a/drivers/gpio/gpio-davinci.c
> > +++ b/drivers/gpio/gpio-davinci.c
> > @@ -257,6 +257,9 @@ static int davinci_gpio_probe(struct platform_device *pdev)
> >  	spin_lock_init(&chips->lock);
> >  
> >  	nbank = DIV_ROUND_UP(ngpio, 32);
> > +    if (nbank > MAX_REGS_BANKS || nbank > 5) {
> > +        nbank = MAX_REGS_BANKS < 5 ? MAX_REGS_BANKS : 5;
> > +	}
> 
> Static analysis warnings make no sense until you provide a reliable way
> to trigger the problem on real systems.

This patch isn't correct, but we merge a few static checker fixes every
day.

regards,
dan carpenter



More information about the lvc-project mailing list