[PATCH][next] gpio: xilinx: Fix potential integer overflow on shift of a u32 int

Andy Shevchenko andy.shevchenko at gmail.com
Mon May 17 00:04:59 PDT 2021


On Thu, May 13, 2021 at 1:04 PM David Laight <David.Laight at aculab.com> wrote:
> > From: Colin Ian King <colin.king at canonical.com>

> > @@ -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;
> >  }
>
> That code looks dubious on 32bit architectures.
>
> I don't have 02b3f84d9080 in any of my source trees.

Can you please be more specific on which code is dubious on 32-bit
arches and why?

> But that patch may itself be very dubious.
>
> Since the hardware requires explicit bits be set, relying
> on the bitmap functions seems pointless and possibly wrong.
> Clearly they cause additional problems because they use long[]
> and here the code needs u32[].

-- 
With Best Regards,
Andy Shevchenko



More information about the linux-arm-kernel mailing list