Re: [RFC PATCH 1/1] idr: do not create idr if new id would be outside given range
From: Matthew Wilcox
Date: Thu Nov 27 2025 - 08:38:09 EST
On Thu, Nov 27, 2025 at 10:27:32AM +0100, Jan Sokolowski wrote:
> @@ -88,6 +89,11 @@ int idr_alloc(struct idr *idr, void *ptr, int start, int end, gfp_t gfp)
> if (ret)
> return ret;
>
> + if (WARN_ON_ONCE(id < start || (id >= end && end != 0))) {
> + idr_remove(idr, id);
> + return -EINVAL;
> + }
This is certainly the wrong way to fix any problem that does exist.
And it should return -ENOSPC, not -EINVAL. -EINVAL is "the arguments
are wrong", not "the data structure is full".
I'll go read the thread now.