From: Alice Ryhl Date: Tue, 11 Nov 2025 14:23:34 +0000 (+0000) Subject: rust: list: add warning to List::remove docs about mem::take X-Git-Tag: v6.19-rc1~65^2~35 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2c8ad5cfc22dba7d0b3b3ddfec0a75d8ea4169c3;p=thirdparty%2Fkernel%2Flinux.git rust: list: add warning to List::remove docs about mem::take The previous patches in this series illustrate why the List::remove method is really dangerous. I think the real takeaway here is to replace the linked lists with a different data structure without this unsafe footgun, but for now we fix the bugs and add a warning to the docs. Signed-off-by: Alice Ryhl Acked-by: Miguel Ojeda Link: https://patch.msgid.link/20251111-binder-fix-list-remove-v1-3-8ed14a0da63d@google.com Signed-off-by: Greg Kroah-Hartman --- diff --git a/rust/kernel/list.rs b/rust/kernel/list.rs index 7355bbac16a7f..8349ff32fc37f 100644 --- a/rust/kernel/list.rs +++ b/rust/kernel/list.rs @@ -576,6 +576,9 @@ impl, const ID: u64> List { /// This returns `None` if the item is not in the list. (Note that by the safety requirements, /// this means that the item is not in any list.) /// + /// When using this method, be careful with using `mem::take` on the same list as that may + /// result in violating the safety requirements of this method. + /// /// # Safety /// /// `item` must not be in a different linked list (with the same id).