Commit c5341ec8 authored by Rasmus Villemoes's avatar Rasmus Villemoes Committed by Linus Torvalds

lib: bitmap: add missing mask in bitmap_shift_right

There is no guarantee that *src does not contain garbage bits outside
the lower nbits, so we need to mask it before the shift-and-assign.
Signed-off-by: default avatarRasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 2ac521d3
...@@ -284,7 +284,7 @@ static inline void bitmap_shift_right(unsigned long *dst, ...@@ -284,7 +284,7 @@ static inline void bitmap_shift_right(unsigned long *dst,
const unsigned long *src, int n, int nbits) const unsigned long *src, int n, int nbits)
{ {
if (small_const_nbits(nbits)) if (small_const_nbits(nbits))
*dst = *src >> n; *dst = (*src & BITMAP_LAST_WORD_MASK(nbits)) >> n;
else else
__bitmap_shift_right(dst, src, n, nbits); __bitmap_shift_right(dst, src, n, nbits);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment