Skip to content

Commit 4d3b7a6

Browse files
committed
rust: workqueue: fix safety comments in WorkItemPointer for Pin<KBox>
The safety comments in the `WorkItemPointer` implementation for `Pin<KBox<T>>` 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 <onur-ozkan@users.noreply.github.com> Link: #1233 Signed-off-by: zanni098 <zuhaibkhann098@gmail.com>
1 parent 025fd4b commit 4d3b7a6

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

rust/kernel/workqueue.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -890,9 +890,9 @@ where
890890
unsafe extern "C" fn run(ptr: *mut bindings::work_struct) {
891891
// The `__enqueue` method always uses a `work_struct` stored in a `Work<T, ID>`.
892892
let ptr = ptr.cast::<Work<T, ID>>();
893-
// SAFETY: This computes the pointer that `__enqueue` got from `Arc::into_raw`.
893+
// SAFETY: This computes the pointer that `__enqueue` got from `KBox::into_raw`.
894894
let ptr = unsafe { T::work_container_of(ptr) };
895-
// SAFETY: This pointer comes from `Arc::into_raw` and we've been given back ownership.
895+
// SAFETY: This pointer comes from `KBox::into_raw` and we've been given back ownership.
896896
let boxed = unsafe { KBox::from_raw(ptr) };
897897
// SAFETY: The box was already pinned when it was enqueued.
898898
let pinned = unsafe { Pin::new_unchecked(boxed) };

0 commit comments

Comments
 (0)