This is a note to let you know that I've just added the patch titled rust: arc: add explicit `drop()` around `Box::from_raw()` to the 6.6-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: rust-arc-add-explicit-drop-around-box-from_raw.patch and it can be found in the queue-6.6 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 828176d037e29f813792a8b3ac1591834240e96f Mon Sep 17 00:00:00 2001 From: Miguel Ojeda <ojeda@xxxxxxxxxx> Date: Wed, 23 Aug 2023 18:02:42 +0200 Subject: rust: arc: add explicit `drop()` around `Box::from_raw()` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Miguel Ojeda <ojeda@xxxxxxxxxx> commit 828176d037e29f813792a8b3ac1591834240e96f upstream. `Box::from_raw()` is `#[must_use]`, which means the result cannot go unused. In Rust 1.71.0, this was not detected because the block expression swallows the diagnostic [1]: unsafe { Box::from_raw(self.ptr.as_ptr()) }; It would have been detected, however, if the line had been instead: unsafe { Box::from_raw(self.ptr.as_ptr()); } i.e. the semicolon being inside the `unsafe` block, rather than outside. In Rust 1.72.0, the compiler started warning about this [2], so without this patch we will get: error: unused return value of `alloc::boxed::Box::<T>::from_raw` that must be used --> rust/kernel/sync/arc.rs:302:22 | 302 | unsafe { Box::from_raw(self.ptr.as_ptr()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: call `drop(Box::from_raw(ptr))` if you intend to drop the `Box` = note: `-D unused-must-use` implied by `-D warnings` help: use `let _ = ...` to ignore the resulting value | 302 | unsafe { let _ = Box::from_raw(self.ptr.as_ptr()); }; | +++++++ + Thus add an add an explicit `drop()` as the `#[must_use]`'s annotation suggests (instead of the more general help line). Link: https://github.com/rust-lang/rust/issues/104253 [1] Link: https://github.com/rust-lang/rust/pull/112529 [2] Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@xxxxxxxxx> Reviewed-by: Gary Guo <gary@xxxxxxxxxxx> Reviewed-by: Alice Ryhl <aliceryhl@xxxxxxxxxx> Reviewed-by: Andreas Hindborg <a.hindborg@xxxxxxxxxxx> Reviewed-by: Björn Roy Baron <bjorn3_gh@xxxxxxxxxxxxxx> Link: https://lore.kernel.org/r/20230823160244.188033-2-ojeda@xxxxxxxxxx Signed-off-by: Miguel Ojeda <ojeda@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- rust/kernel/sync/arc.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/rust/kernel/sync/arc.rs +++ b/rust/kernel/sync/arc.rs @@ -302,7 +302,7 @@ impl<T: ?Sized> Drop for Arc<T> { // The count reached zero, we must free the memory. // // SAFETY: The pointer was initialised from the result of `Box::leak`. - unsafe { Box::from_raw(self.ptr.as_ptr()) }; + unsafe { drop(Box::from_raw(self.ptr.as_ptr())) }; } } } Patches currently in stable-queue which might be from ojeda@xxxxxxxxxx are queue-6.6/rust-upgrade-to-rust-1.72.1.patch queue-6.6/rust-task-remove-redundant-explicit-link.patch queue-6.6/rust-upgrade-to-rust-1.73.0.patch queue-6.6/rust-arc-add-explicit-drop-around-box-from_raw.patch queue-6.6/rust-print-use-explicit-link-in-documentation.patch