summaryrefslogtreecommitdiff
path: root/rust/kernel/types.rs
diff options
context:
space:
mode:
authorAndreas Hindborg <a.hindborg@kernel.org>2025-06-12 15:09:44 +0200
committerMiguel Ojeda <ojeda@kernel.org>2025-07-14 23:55:24 +0200
commita68a6bef0e75fb9e5aea1399d8538f4e3584dab1 (patch)
tree9f168f8dfb5ae7a615e62b58f10f4a44c4355c35 /rust/kernel/types.rs
parent12717ebeffcf3e34063dbc1e1b7f34924150c7c9 (diff)
rust: types: require `ForeignOwnable::into_foreign` return non-null
The intended implementations of `ForeignOwnable` will not return null pointers from `into_foreign`, as this would render the implementation of `try_from_foreign` useless. Current users of `ForeignOwnable` rely on `into_foreign` returning non-null pointers. So require `into_foreign` to return non-null pointers. Suggested-by: Benno Lossin <lossin@kernel.org> Suggested-by: Alice Ryhl <aliceryhl@google.com> Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org> Reviewed-by: Benno Lossin <lossin@kernel.org> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Link: https://lore.kernel.org/r/20250612-pointed-to-v3-2-b009006d86a1@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Diffstat (limited to 'rust/kernel/types.rs')
-rw-r--r--rust/kernel/types.rs1
1 files changed, 1 insertions, 0 deletions
diff --git a/rust/kernel/types.rs b/rust/kernel/types.rs
index c156808a78d3..63a2559a545f 100644
--- a/rust/kernel/types.rs
+++ b/rust/kernel/types.rs
@@ -43,6 +43,7 @@ pub unsafe trait ForeignOwnable: Sized {
/// # Guarantees
///
/// - Minimum alignment of returned pointer is [`Self::FOREIGN_ALIGN`].
+ /// - The returned pointer is not null.
///
/// [`from_foreign`]: Self::from_foreign
/// [`try_from_foreign`]: Self::try_from_foreign