From fafa88583c6d49483c967d341a1c21b1c9f31ceb Mon Sep 17 00:00:00 2001 From: "Matthew Wilcox (Oracle)" Date: Sat, 2 Nov 2019 00:25:08 -0400 Subject: [PATCH] idr: Fix idr_alloc_u32 on 32-bit systems BugLink: https://bugs.launchpad.net/bugs/1855787 [ Upstream commit b7e9728f3d7fc5c5c8508d99f1675212af5cfd49 ] 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) Signed-off-by: Sasha Levin Signed-off-by: Kamal Mostafa Signed-off-by: Kleber Sacilotto de Souza --- lib/radix-tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/radix-tree.c b/lib/radix-tree.c index 434b3270ca45..7c92df492c6f 100644 --- a/lib/radix-tree.c +++ b/lib/radix-tree.c @@ -2180,7 +2180,7 @@ void __rcu **idr_get_free_cmn(struct radix_tree_root *root, 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; -- 2.39.2