rust: workqueue: fix SAFETY comments in Pin<KBox<T>> run()
PATCH 1/1 rust: workqueue: fix SAFETY comments in Pin<KBox<T>> run()
The WorkItemPointer implementation for Pin<KBox<T>> was copied from the Arc<T> implementation, and the SAFETY comments in its run() function still claim that the pointer comes from Arc::into_raw.
However, the matching RawWorkItem::__enqueue implementation for Pin<KBox<T>> obtains the pointer from KBox::into_raw, which is also what makes the subsequent KBox::from_raw call sound.
Update the comments to reference the correct function. No functional change.
This patch was prepared with the help of an AI coding assistant (Claude Code), which found the mismatch and wrote the change; it was reviewed and build-tested with CLIPPY=1 by the submitter.
--- rust/kernel/workqueue.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
rust/kernel/workqueue.rs +2 -2
@@ -890,9 +890,9 @@ unsafe impl<T, const ID: u64> WorkItemPointer<ID> for Pin<KBox<T>>unsafe extern "C" fn run (ptr: *mut bindings::work_struct ) {// The `__enqueue` method always uses a `work_struct` stored in a `Work<T, ID>`. let ptr = ptr.cast ::<Work <T ,ID >>(); -// SAFETY: This computes the pointer that `__enqueue` got from `Arc::into_raw`. +// SAFETY: This computes the pointer that `__enqueue` got from `KBox::into_raw`. let ptr =unsafe {T ::work_container_of (ptr) }; -// SAFETY: This pointer comes from `Arc::into_raw` and we've been given back ownership. +// SAFETY: This pointer comes from `KBox::into_raw` and we've been given back ownership. let boxed =unsafe {KBox ::from_raw (ptr) };// SAFETY: The box was already pinned when it was enqueued. let pinned =unsafe {Pin ::new_unchecked (boxed) };
---
base-commit: 4405c18c95d2d0f99f6c581ef0ee8591a1aa6ccd
change-id: 20261122-rust-workqueue-safety-comment-4bde8f258d52
Best regards,
Signature · 1 line
Andrea Tontini <[email protected]>
Quoted 4 lines · Andrea Tontini
This patch was prepared with the help of an AI coding assistant (Claude Code), which found the mismatch and wrote the change; it was reviewed and build-tested with CLIPPY=1 by the submitter.
Thanks for the patch! This would normally go below the --- line (sometimes we do mention testing if there is something in particular important to say, but build-testing and CLIPPY=1 are always expected, so there is no need to mention it, especially in the commit message).
Also, please see this patch as well:
https://lore.kernel.org/rust-for-linux/[email protected]/
Cc'ing Sagar.
Thanks!
Cheers,
Miguel