ida: Fix crash in ida_free when the bitmap is empty
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Thu, 21 Dec 2023 16:53:57 +0000 (16:53 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 20 Jan 2024 10:51:46 +0000 (11:51 +0100)
commitffcaafdb8be64555e9928d943a3655c755dba92b
treec3319b1850767d660b4573210b956e24c8f00e10
parent766c6c1dd1403a5212888c74647532800169345c
ida: Fix crash in ida_free when the bitmap is empty

[ Upstream commit af73483f4e8b6f5c68c9aa63257bdd929a9c194a ]

The IDA usually detects double-frees, but that detection failed to
consider the case when there are no nearby IDs allocated and so we have a
NULL bitmap rather than simply having a clear bit.  Add some tests to the
test-suite to be sure we don't inadvertently reintroduce this problem.
Unfortunately they're quite noisy so include a message to disregard
the warnings.

Reported-by: Zhenghan Wang <wzhmmmmm@gmail.com>
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
lib/idr.c
lib/test_ida.c