rust: workqueue: fix SAFETY comment Arc refs in Pin<KBox<T>>
Subsystems (2)
PATCH v2 1/1 rust: workqueue: fix SAFETY comment Arc refs in Pin<KBox<T>>
The WorkItemPointer implementation for Pin<KBox<T>> contained SAFETY comments that incorrectly referenced Arc::into_raw instead of KBox::into_raw. This implementation uses KBox, not Arc, so update the comments to accurately reflect the actual ownership transfer.
--- rust/kernel/workqueue.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
rust/kernel/workqueue.rs +3 -2
@@ -890,9 +890,10 @@ 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 have been given back ownership, +// as the workqueue guarantees `run` is called exactly once. let boxed =unsafe {KBox ::from_raw (ptr) };// SAFETY: The box was already pinned when it was enqueued. let pinned =unsafe {Pin ::new_unchecked (boxed) };
Signature · 1 line
2.54.0
Quoted 11 lines · Sagar Taunk
The
WorkItemPointerimplementation forPin<KBox<T>>contained SAFETY comments that incorrectly referencedArc::into_rawinstead ofKBox::into_raw. This implementation usesKBox, notArc, so update the comments to accurately reflect the actual ownership transfer.Fixes 8373147ce496 ("rust: treewide: switch to our kernel `Box` type")Suggested-by Onur Özkan <[email protected]>Signed-off-by Sagar Taunk <[email protected]>
I should have mentioned that, in the case of making it a fix, one usually uses Reported-by: and Closes: instead of Suggested-by: and Link:
No need for v3 for that I would say -- the maintainers may fix this on apply :)
Thanks!
Cheers,
Miguel
Thanks for the feedback! I'll use Reported-by and Closes next time.
Cheers,
Sagar