From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Date: Sat, 2 Nov 2019 00:25:08 -0400
Subject: idr: Fix idr_alloc_u32 on 32-bit systems
Git-commit: b7e9728f3d7fc5c5c8508d99f1675212af5cfd49
Patch-mainline: 5.4-rc7
References: bnc#1151927 5.3.15
Attempting to allocate an entry at 0xffffffff when one is already
present would succeed in allocating one at 2^32, which would confuse
everything. Return -ENOSPC in this case, as expected.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
lib/radix-tree.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/lib/radix-tree.c
+++ b/lib/radix-tree.c
@@ -1529,7 +1529,7 @@ void __rcu **idr_get_free(struct radix_t
offset = radix_tree_find_next_bit(node, IDR_FREE,
offset + 1);
start = next_index(start, node, offset);
- if (start > max)
+ if (start > max || start == 0)
return ERR_PTR(-ENOSPC);
while (offset == RADIX_TREE_MAP_SIZE) {
offset = node->offset + 1;