summaryrefslogtreecommitdiff
path: root/rust/kernel
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2026-10-21 09:49:47 -1000
committerLinus Torvalds <torvalds@linux-foundation.org>2026-10-21 09:49:47 -1000
commit9ba46df344883ca8bade47c0ed7aebf80a1e07b9 (patch)
treeaa43e93101bf0f28f00e4c0eaeaf4efe68533240 /rust/kernel
parent22a78a25438d246e4e951960523bee6a5155897d (diff)
parenta73b4d1fa7d334a5f7de5bb0a14726530f66196e (diff)
downloadlinux-9ba46df344883ca8bade47c0ed7aebf80a1e07b9.tar.gz
linux-9ba46df344883ca8bade47c0ed7aebf80a1e07b9.zip
Merge tag 'bitmap-for-v7.4-rc1' of https://github.com/norov/linux
Pull bitmap updates from Yury Norov: "This includes __MAKE_OP() macro removal from me with the follow-up from Mark, cleanups for bitmaps parser from Shashank and a couple Rust docs fixes from Georgios" * tag 'bitmap-for-v7.4-rc1' of https://github.com/norov/linux: rust: bitmap: document panics in `next_bit` and `next_zero_bit` rust: id_pool: document panics in `find_unused_id` and `release_id` bitmap: test bitmap_parselist() with a group size close to UINT_MAX bitmap: bitmap_parselist(): don't wrap around on a huge group size bitmap: test bitmap_parselist() with text after the group size bitmap: bitmap_parselist(): reject trailing characters after group size bitmap: test bitmap_parse() with an illegal character before 8 hex digits bitmap: bitmap_parse(): reject non-hex character before 8 digits bitfield: Restore be16_replace_bits() bitfield: get rid of __MAKE_OP machinery
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);