]> git.dujemihanovic.xyz Git - linux.git/commit
bitmap: relax find_nth_bit() limitation on return value
authorYury Norov <yury.norov@gmail.com>
Thu, 2 May 2024 17:12:56 +0000 (10:12 -0700)
committerYury Norov <yury.norov@gmail.com>
Thu, 9 May 2024 16:25:08 +0000 (09:25 -0700)
commit0b2811ba11b04353033237359c9d042eb0cdc1c1
tree457edbccba4f262f89ac844914158f7705857ff4
parent77db1920a88103e8ef9ee58130df7c970aea3d17
bitmap: relax find_nth_bit() limitation on return value

The function claims to return the bitmap size, if Nth bit doesn't exist.
This rule is violated in inline case because the fns() that is used
there doesn't know anything about size of the bitmap.

So, relax this requirement to '>= size', and make the outline
implementation a bit cheaper.

All in-tree kernel users of find_nth_bit() are safe against that.

Reported-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Closes: https://lore.kernel.org/all/Zi50cAgR8nZvgLa3@yury-ThinkPad/T/#m6da806a0525e74dcc91f35e5f20766ed4e853e8a
Signed-off-by: Yury Norov <yury.norov@gmail.com>
include/linux/find.h
lib/find_bit.c
lib/test_bitmap.c