lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAH5fLgi1iGi9kMzDjEb_jQzzAm+y4pmfNXSneoLHS6o+sCv_8w@mail.gmail.com>
Date: Tue, 28 Jan 2025 15:35:22 +0100
From: Alice Ryhl <aliceryhl@...gle.com>
To: Lyude Paul <lyude@...hat.com>
Cc: rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org, 
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>, "Rafael J. Wysocki" <rafael@...nel.org>, 
	Danilo Krummrich <dakr@...nel.org>, Miguel Ojeda <ojeda@...nel.org>, Alex Gaynor <alex.gaynor@...il.com>, 
	Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>, 
	Björn Roy Baron <bjorn3_gh@...tonmail.com>, 
	Benno Lossin <benno.lossin@...ton.me>, Andreas Hindborg <a.hindborg@...nel.org>, 
	Trevor Gross <tmgross@...ch.edu>
Subject: Re: [PATCH 1/2] rust/kernel: Add platform::Device::from_raw()

On Thu, Jan 23, 2025 at 12:54 AM Lyude Paul <lyude@...hat.com> wrote:
>
> Just a convenience method to convert from a raw struct platform_device
> pointer into a platform::Device object, which we'll be using in the next
> commit.
>
> Signed-off-by: Lyude Paul <lyude@...hat.com>
> ---
>  rust/kernel/platform.rs | 17 ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/rust/kernel/platform.rs b/rust/kernel/platform.rs
> index 50e6b04218132..75dc7824eccf4 100644
> --- a/rust/kernel/platform.rs
> +++ b/rust/kernel/platform.rs
> @@ -14,7 +14,7 @@
>      ThisModule,
>  };
>
> -use core::ptr::addr_of_mut;
> +use core::ptr::{NonNull, addr_of_mut};
>
>  /// An adapter for the registration of platform drivers.
>  pub struct Adapter<T: Driver>(T);
> @@ -186,6 +186,21 @@ unsafe fn from_dev(dev: ARef<device::Device>) -> Self {
>          Self(dev)
>      }
>
> +    /// Convert a raw pointer to a `struct platform_device` into a `Device`.
> +    ///
> +    /// # Safety
> +    ///
> +    /// * `pdev` must be a valid pointer to a `bindings::platform_device`.
> +    /// * The caller must be guaranteed to hold at least one reference to `pdev`.

I would probably say that the caller must *transfer ownership* of one
refcount or something like that.

Alice

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ