From 4d3b7a669439417f7c796df885f06e98c83c8b89 Mon Sep 17 00:00:00 2001 From: zanni098 Date: Wed, 3 Jun 2026 18:56:36 +0000 Subject: [PATCH] rust: workqueue: fix safety comments in WorkItemPointer for Pin The safety comments in the `WorkItemPointer` implementation for `Pin>` incorrectly refer to `Arc::into_raw`. This implementation uses `KBox`, not `Arc`; the comments were copied from the `Arc` implementation. The pointer recovered in `run()` originates from `KBox::into_raw` in the corresponding `__enqueue`, so correct the comments to refer to `KBox`. Suggested-by: onur-ozkan Link: https://github.com/Rust-for-Linux/linux/issues/1233 Signed-off-by: zanni098 --- rust/kernel/workqueue.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/kernel/workqueue.rs b/rust/kernel/workqueue.rs index 7e253b6f299ce3..2c07785d446e7f 100644 --- a/rust/kernel/workqueue.rs +++ b/rust/kernel/workqueue.rs @@ -890,9 +890,9 @@ where unsafe extern "C" fn run(ptr: *mut bindings::work_struct) { // The `__enqueue` method always uses a `work_struct` stored in a `Work`. let ptr = ptr.cast::>(); - // 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) };