diff options
author | Matthew Wilcox (Oracle) <willy@infradead.org> | 2019-11-02 00:25:08 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-12-05 09:19:40 +0100 |
commit | 8ef58b82d1e48378a53d2390629f23fba3aaf8c2 (patch) | |
tree | f6f96929ac8e124932b7cd91982e5040e3a76632 /lib | |
parent | 88358c7610cc29234f795bb9deca4ece95fd2c1b (diff) | |
download | linux-stable-8ef58b82d1e48378a53d2390629f23fba3aaf8c2.tar.gz linux-stable-8ef58b82d1e48378a53d2390629f23fba3aaf8c2.tar.bz2 linux-stable-8ef58b82d1e48378a53d2390629f23fba3aaf8c2.zip |
idr: Fix idr_alloc_u32 on 32-bit systems
[ 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) <willy@infradead.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/radix-tree.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/radix-tree.c b/lib/radix-tree.c index bc03ecc4dfd2..e5cab5c4e383 100644 --- a/lib/radix-tree.c +++ b/lib/radix-tree.c @@ -2172,7 +2172,7 @@ void __rcu **idr_get_free(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; |