From: Rasmus Villemoes Date: Wed, 6 Aug 2014 23:10:20 +0000 (-0700) Subject: lib: bitmap: add missing mask in bitmap_shift_right X-Git-Tag: v4.9.8~5947^2~33 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c5341ec8904ebff50f365a2626da6ab525d63b9e;p=platform%2Fkernel%2Flinux-rpi3.git 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 Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h index 2100378..75df61d9 100644 --- a/include/linux/bitmap.h +++ b/include/linux/bitmap.h @@ -284,7 +284,7 @@ static inline void bitmap_shift_right(unsigned long *dst, const unsigned long *src, int n, int nbits) { if (small_const_nbits(nbits)) - *dst = *src >> n; + *dst = (*src & BITMAP_LAST_WORD_MASK(nbits)) >> n; else __bitmap_shift_right(dst, src, n, nbits); }