Re: [PATCH] rust: id_pool: document panics in `find_unused_id` and `release_id`

From: Alexandre Courbot

Date: Sun Aug 30 2026 - 21:08:43 EST


On Sun Aug 30, 2026 at 12:34 AM JST, Georgios Androutsopoulos wrote:
> `find_unused_id()` calls `Bitmap::next_zero_bit()` and `release_id()`
> calls `Bitmap::clear_bit()`, both of which panic when
> `CONFIG_RUST_BITMAP_HARDENED` is enabled and the index is out of
> bounds. Neither `IdPool` method documents this.
>
> Add the missing `# Panics` sections and state the bounds requirement
> on `offset` and `id`.
>
> Signed-off-by: Georgios Androutsopoulos <georgeandrout13@xxxxxxxxx>

Reviewed-by: Alexandre Courbot <acourbot@xxxxxxxxxx>

One small nit below.

> ---
> rust/kernel/id_pool.rs | 15 ++++++++++++++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/rust/kernel/id_pool.rs b/rust/kernel/id_pool.rs
> index 384753fe0..ae6960d7f 100644
> --- a/rust/kernel/id_pool.rs
> +++ b/rust/kernel/id_pool.rs
> @@ -224,7 +224,13 @@ pub fn grow(&mut self, mut resizer: PoolResizer) {
> /// Finds an unused ID in the bitmap.
> ///
> /// Upon success, returns its index. Otherwise, returns [`None`]
> - /// to indicate that a [`Self::grow_request`] is needed.
> + /// to indicate that a [`Self::grow_request`] is needed. `offset` must be
> + /// in bounds.

s/in/within maybe?