aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/bitmap.h
diff options
context:
space:
mode:
authorRasmus Villemoes <linux@rasmusvillemoes.dk>2014-08-06 19:10:20 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-08-06 21:01:27 -0400
commitc5341ec8904ebff50f365a2626da6ab525d63b9e (patch)
tree0acb8e7d30405e97097d226a8f4d558470e408fe /include/linux/bitmap.h
parent2ac521d3325a24f01c1f1e86c74537b831d282c5 (diff)
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: Rasmus Villemoes <linux@rasmusvillemoes.dk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/bitmap.h')
-rw-r--r--include/linux/bitmap.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
index 210037833356..75df61d9ecfb 100644
--- a/include/linux/bitmap.h
+++ b/include/linux/bitmap.h
@@ -284,7 +284,7 @@ static inline void bitmap_shift_right(unsigned long *dst,
284 const unsigned long *src, int n, int nbits) 284 const unsigned long *src, int n, int nbits)
285{ 285{
286 if (small_const_nbits(nbits)) 286 if (small_const_nbits(nbits))
287 *dst = *src >> n; 287 *dst = (*src & BITMAP_LAST_WORD_MASK(nbits)) >> n;
288 else 288 else
289 __bitmap_shift_right(dst, src, n, nbits); 289 __bitmap_shift_right(dst, src, n, nbits);
290} 290}