Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 10 May 2015 22:04:43 +0000 (UTC)
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r282741 - head/sys/ofed/include/linux
Message-ID:  <201505102204.t4AM4huc096973@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: markj
Date: Sun May 10 22:04:42 2015
New Revision: 282741
URL: https://svnweb.freebsd.org/changeset/base/282741

Log:
  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

Modified:
  head/sys/ofed/include/linux/bitops.h

Modified: head/sys/ofed/include/linux/bitops.h
==============================================================================
--- head/sys/ofed/include/linux/bitops.h	Sun May 10 22:03:59 2015	(r282740)
+++ head/sys/ofed/include/linux/bitops.h	Sun May 10 22:04:42 2015	(r282741)
@@ -165,6 +165,8 @@ find_next_bit(unsigned long *addr, unsig
 		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, 
 		mask = ~(*addr) & ~BIT_MASK(offs);
 		if (mask)
 			return (bit + __ffsl(mask));
+		if (size - bit <= BITS_PER_LONG)
+			return (size);
 		bit += BITS_PER_LONG;
 		addr++;
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201505102204.t4AM4huc096973>