pinctrl: nuvoton: wpcm450: off by one in wpcm450_gpio_register()
Subsystems (4)
PATCH 1/1 pinctrl: nuvoton: wpcm450: off by one in wpcm450_gpio_register()
The > WPCM450_NUM_BANKS should be >= or it leads to an out of bounds access on the next line.
Fixes a1d1e0e3d80a ("pinctrl: nuvoton: Add driver for WPCM450")
Signed-off-by Dan Carpenter <[email protected]>
--- drivers/pinctrl/nuvoton/pinctrl-wpcm450.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/nuvoton/pinctrl-wpcm450.c +1 -1
@@ -1043,7 +1043,7 @@ static int wpcm450_gpio_register(struct platform_device *pdev, gpio = &pctrl->gpio_bank[reg]; gpio->pctrl = pctrl; -if (reg >WPCM450_NUM_BANKS ) +if (reg >=WPCM450_NUM_BANKS )return dev_err_probe (dev, -EINVAL ,"GPIO index %d out of range!\n" , reg);
Signature · 1 line
2.20.1
Quoted 2 lines · Dan Carpenter
The >
WPCM450_NUM_BANKSshould be >= or it leads to an out of bounds access on the next line.
True.
Quoted 3 lines
Fixes a1d1e0e3d80a ("pinctrl: nuvoton: Add driver for WPCM450")Signed-off-by Dan Carpenter <[email protected]>---
Reviewed-by Jonathan Neuschäfer <[email protected]>
Thanks,
Jonathan
Quoted 19 lines
drivers/pinctrl/nuvoton/pinctrl-wpcm450.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pinctrl/nuvoton/pinctrl-wpcm450.c +1
-1@@ -1043,7 +1043,7 @@ static int wpcm450_gpio_register(struct platform_device *pdev, gpio = &pctrl->gpio_bank[reg]; gpio->pctrl = pctrl; -if (reg >WPCM450_NUM_BANKS ) +if (reg >=WPCM450_NUM_BANKS )return dev_err_probe (dev, -EINVAL ,"GPIO index %d out of range!\n" , reg);Signature · 1 line
2.20.1
Quoted 5 lines · Dan Carpenter
The >
WPCM450_NUM_BANKSshould be >= or it leads to an out of bounds access on the next line.Fixes a1d1e0e3d80a ("pinctrl: nuvoton: Add driver for WPCM450")Signed-off-by Dan Carpenter <[email protected]>
Patch applied!
Yours,
Linus Walleij