diff options
author | markj <markj@FreeBSD.org> | 2015-05-10 22:04:42 +0000 |
---|---|---|
committer | markj <markj@FreeBSD.org> | 2015-05-10 22:04:42 +0000 |
commit | ba9d713de764ef16cf2436b4c221a6a69eb6e631 (patch) | |
tree | 003516ddbc0592dbb861907e05f5649f7b8dd9df /sys/ofed/include | |
parent | bc53a56c01080bcfa62c2433c36de981d18eb977 (diff) | |
download | FreeBSD-src-ba9d713de764ef16cf2436b4c221a6a69eb6e631.zip FreeBSD-src-ba9d713de764ef16cf2436b4c221a6a69eb6e631.tar.gz |
find_next_bit() and find_next_zero_bit(): if the caller-specified offset
lies within the last block of the bit set and no bits are set beyond the
offset, terminate the search immediately instead of continuing as though
there are further blocks in the set and subsequently returning an incorrect
result.
MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division
Diffstat (limited to 'sys/ofed/include')
-rw-r--r-- | sys/ofed/include/linux/bitops.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/sys/ofed/include/linux/bitops.h b/sys/ofed/include/linux/bitops.h index f225fdc..d3f82fe 100644 --- a/sys/ofed/include/linux/bitops.h +++ b/sys/ofed/include/linux/bitops.h @@ -165,6 +165,8 @@ find_next_bit(unsigned long *addr, unsigned long size, unsigned long offset) mask = (*addr) & ~BIT_MASK(offs); if (mask) return (bit + __ffsl(mask)); + if (size - bit <= BITS_PER_LONG) + return (size); bit += BITS_PER_LONG; addr++; } @@ -203,6 +205,8 @@ find_next_zero_bit(unsigned long *addr, unsigned long size, mask = ~(*addr) & ~BIT_MASK(offs); if (mask) return (bit + __ffsl(mask)); + if (size - bit <= BITS_PER_LONG) + return (size); bit += BITS_PER_LONG; addr++; } |