summaryrefslogtreecommitdiff
path: root/rust/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'rust/kernel')
-rw-r--r--rust/kernel/bitmap.rs17
-rw-r--r--rust/kernel/id_pool.rs15
2 files changed, 29 insertions, 3 deletions
diff --git a/rust/kernel/bitmap.rs b/rust/kernel/bitmap.rs
index b27e0ec80d64..b51c8a96f1a8 100644
--- a/rust/kernel/bitmap.rs
+++ b/rust/kernel/bitmap.rs
@@ -459,7 +459,13 @@ impl Bitmap {
/// Finds next set bit, starting from `start`.
///
- /// Returns `None` if `start` is greater or equal to `self.nbits`.
+ /// Returns `None` if no bits are set on or after the given index. The
+ /// index `start` must be in bounds.
+ ///
+ /// # Panics
+ ///
+ /// Panics if `CONFIG_RUST_BITMAP_HARDENED` is enabled and `start` is
+ /// out of bounds.
#[inline]
pub fn next_bit(&self, start: usize) -> Option<usize> {
bitmap_assert!(
@@ -479,7 +485,14 @@ impl Bitmap {
}
/// Finds next zero bit, starting from `start`.
- /// Returns `None` if `start` is greater than or equal to `self.len()`.
+ ///
+ /// Returns `None` if no bits are zero on or after the given index. The
+ /// index `start` must be in bounds.
+ ///
+ /// # Panics
+ ///
+ /// Panics if `CONFIG_RUST_BITMAP_HARDENED` is enabled and `start` is
+ /// out of bounds.
#[inline]
pub fn next_zero_bit(&self, start: usize) -> Option<usize> {
bitmap_assert!(
diff --git a/rust/kernel/id_pool.rs b/rust/kernel/id_pool.rs
index 384753fe0e44..c8b346554802 100644
--- a/rust/kernel/id_pool.rs
+++ b/rust/kernel/id_pool.rs
@@ -224,7 +224,13 @@ impl IdPool {
/// 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
+ /// within bounds.
+ ///
+ /// # Panics
+ ///
+ /// Panics if `CONFIG_RUST_BITMAP_HARDENED` is enabled and `offset` is out
+ /// of bounds.
#[inline]
#[must_use]
pub fn find_unused_id(&mut self, offset: usize) -> Option<UnusedId<'_>> {
@@ -236,6 +242,13 @@ impl IdPool {
}
/// Releases an ID.
+ ///
+ /// The `id` must be within bounds.
+ ///
+ /// # Panics
+ ///
+ /// Panics if `CONFIG_RUST_BITMAP_HARDENED` is enabled and `id` is out of
+ /// bounds.
#[inline]
pub fn release_id(&mut self, id: usize) {
self.map.clear_bit(id);