Apparently, bitmap_and is supposed to return whether the new bitmap is empty. But it didn't take potential garbage bits in the last word into account.
Showing the changes to include/linux/bitmap.h (1 of 2 files). Show all
Unified · Split
| @@ -191,7 +191,7 @@ static inline int bitmap_and(unsigned long *dst, const unsigned long *src1, · 190 unmodified lines | |||
| 191 | const unsigned long *src2, unsigned int nbits) | 191 | const unsigned long *src2, unsigned int nbits) |
| 192 | { | 192 | { |
| 193 | if (small_const_nbits(nbits)) | 193 | if (small_const_nbits(nbits)) |
| 194 | return (*dst = *src1 & *src2) != 0; | 194 | return (*dst = *src1 & *src2 & BITMAP_LAST_WORD_MASK(nbits)) != 0; |
| 195 | return __bitmap_and(dst, src1, src2, nbits); | 195 | return __bitmap_and(dst, src1, src2, nbits); |
| 196 | } | 196 | } |
| 197 | 197 | ||