idr: Fix handling of IDs above INT_MAX

Khalid reported that the kernel selftests are currently failing:

test_bpf: [FAIL]
not ok 1..8 selftests: [FAIL]

He bisected it to 6ce711f2750031d12cec91384ac5cfa0a485b60a ("idr: Make
1-based IDRs more efficient").

The root cause is doing a signed comparison in idr_alloc_u32() instead
of an unsigned comparison.  I went looking for any similar problems and
found a couple (which would each result in the failure to warn in two
situations that aren't supposed to happen).

I knocked up a few test-cases to prove that I was right and added them
to the test-suite.

Reported-by: Khalid Aziz <>
Tested-by: Khalid Aziz <>
Signed-off-by: Matthew Wilcox <>
2 files changed