gpio: gpio-xilinx: Fix integer overflow
Subsystems (3)
PATCH 1/1 gpio: gpio-xilinx: Fix integer overflow
Current implementation is not able to configure more than 32 pins due to incorrect data type. So type casting with unsigned long to avoid it.
--- drivers/gpio/gpio-xilinx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-xilinx.c +1 -1
@@ -99,7 +99,7 @@ static inline void xgpio_set_value32(unsigned long *map, int bit, u32 v)const unsigned long offset = (bit %BITS_PER_LONG ) &BIT (5 ); map[index] &= ~(0xFFFFFFFFul << offset); - map[index] |= v << offset; + map[index] |= (unsigned long )v << offset; }static inline int xgpio_regoffset (struct xgpio_instance *chip,int ch)
Signature · 1 line
2.17.1
Bartosz Golaszewski
AppliedQuoted 25 lines · Srinivas Neeli
Current implementation is not able to configure more than 32 pins due to incorrect data type. So type casting with unsigned long to avoid it.
Fixes 02b3f84d9080 ("xilinx: Switch to use bitmap APIs")Signed-off-by Srinivas Neeli <[email protected]>--- drivers/gpio/gpio-xilinx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpio/gpio-xilinx.c +1
-2@@ -99,7 +99,7 @@ static inline void xgpio_set_value32(unsigned long *map, int bit, u32 v)const unsigned long offset = (bit %BITS_PER_LONG ) &BIT (5 ); map[index] &= ~(0xFFFFFFFFul << offset); - map[index] |= v << offset; + map[index] |= (unsigned long )v << offset; }static inline int xgpio_regoffset (struct xgpio_instance *chip,int ch) --
Quoted 2 lines
2.17.1
Applied, thanks!
Bart
Quoted 8 lines · Bartosz Golaszewski
Quoted 6 lines · Srinivas Neeli
Current implementation is not able to configure more than 32 pins due to incorrect data type. So type casting with unsigned long to avoid it.
Fixes 02b3f84d9080 ("xilinx: Switch to use bitmap APIs")
It doesn't fix anything, I already reject one such "fix" during development of this patch. Thanks!
...
Quoted 9 lines
drivers/gpio/gpio-xilinx.c static inline void xgpio_set_value32(unsigned long *map, int bit, u32 v) · line 103
Quoted 7 lines
drivers/gpio/gpio-xilinx.c +1
-1@@ -99,7 +99,7 @@ static inline void xgpio_set_value32(unsigned long *map, int bit, u32 v)const unsigned long offset = (bit %BITS_PER_LONG ) &BIT (5 ); map[index] &= ~(0xFFFFFFFFul << offset); - map[index] |= v << offset; + map[index] |= (unsigned long )v << offset; }Applied, thanks!
False positive.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 4 lines · Andy Shevchenko
Quoted 3 lines · Bartosz Golaszewski
Quoted 1 line · Srinivas Neeli
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Current implementation is not able to configure more than 32 pins due to incorrect data type. So type casting with unsigned long to avoid it.
Fixes 02b3f84d9080 ("xilinx: Switch to use bitmap APIs")It doesn't fix anything, I already reject one such "fix" during development of this patch. Thanks!
Sorry, not my day, it was something else that time... See below.
Quoted 7 lines
...
Quoted 3 lines
Review c
Quoted 1 line
(quoted diff) +0
-0@@ -99,7 +99,7 @@ cApplied, thanks!
False positive.
Reading again... You mean that
unsigned long x = y << 32;
wouldn't work?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Andy Shevchenko
Reviewed-byQuoted 5 lines · Andy Shevchenko
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · Bartosz Golaszewski
On Thu, Jul 21, 2022 at 9:39 AM Srinivas Neeli
<[email protected]> wrote:
...
Quoted 5 lines
Reading again... You mean that
unsigned long x = y << 32;wouldn't work?
Yeah, I even checked this in asm, and indeed it doesn't work. Don't know what was that about me...
Thanks for the fix,
Signature · 2 lines
With Best Regards, Andy Shevchenko