bitmap: fix end condition in bitmap_find_free_region
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 13 Mar 2009 02:32:51 +0000 (19:32 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 13 Mar 2009 02:32:51 +0000 (19:32 -0700)
commitaa8e4fc68d8024cd3132035d13c3cefa7baeac8f
treeace4457c20730a5a557f91599ba30274a89c46a8
parent9ead64974b05501bbac0d63a47c99fa786d064ba
bitmap: fix end condition in bitmap_find_free_region

Guennadi Liakhovetski noticed that the end condition for the loop in
bitmap_find_free_region() is wrong, and the "return if error" was also
using the wrong conditional that would only trigger if the bitmap was an
exact multiple of the allocation size, which is not necessarily the case
with dma_alloc_from_coherent().

Such a failure would end up in bitmap_find_free_region() accessing
beyond the end of the bitmap.

Reported-by: Guennadi Liakhovetski <lg@denx.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
lib/bitmap.c