Skip to content

Commit 2c8ad5c

Browse files
Darksonngregkh
authored andcommitted
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 <aliceryhl@google.com> Acked-by: Miguel Ojeda <ojeda@kernel.org> Link: https://patch.msgid.link/20251111-binder-fix-list-remove-v1-3-8ed14a0da63d@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 6c37beb commit 2c8ad5c

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

rust/kernel/list.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,9 @@ impl<T: ?Sized + ListItem<ID>, const ID: u64> List<T, ID> {
576576
/// This returns `None` if the item is not in the list. (Note that by the safety requirements,
577577
/// this means that the item is not in any list.)
578578
///
579+
/// When using this method, be careful with using `mem::take` on the same list as that may
580+
/// result in violating the safety requirements of this method.
581+
///
579582
/// # Safety
580583
///
581584
/// `item` must not be in a different linked list (with the same id).

0 commit comments

Comments
 (0)