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: <ec9742a1-45a3-4058-b530-48b2ceb9c5fa@de.bosch.com>
Date: Mon, 3 Jun 2024 09:20:09 +0200
From: Dirk Behme <dirk.behme@...bosch.com>
To: Danilo Krummrich <dakr@...hat.com>, <gregkh@...uxfoundation.org>,
	<rafael@...nel.org>, <bhelgaas@...gle.com>, <ojeda@...nel.org>,
	<alex.gaynor@...il.com>, <wedsonaf@...il.com>, <boqun.feng@...il.com>,
	<gary@...yguo.net>, <bjorn3_gh@...tonmail.com>, <benno.lossin@...ton.me>,
	<a.hindborg@...sung.com>, <aliceryhl@...gle.com>, <airlied@...il.com>,
	<fujita.tomonori@...il.com>, <lina@...hilina.net>, <pstanner@...hat.com>,
	<ajanulgu@...hat.com>, <lyude@...hat.com>
CC: <rust-for-linux@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
	<linux-pci@...r.kernel.org>
Subject: Re: [RFC PATCH 08/11] rust: add devres abstraction

On 20.05.2024 19:25, Danilo Krummrich wrote:
> Add a Rust abstraction for the kernel's devres (device resource
> management) implementation.
> 
> The Devres type acts as a container to manage the lifetime and
> accessibility of device bound resources. Therefore it registers a
> devres callback and revokes access to the resource on invocation.
> 
> Users of the Devres abstraction can simply free the corresponding
> resources in their Drop implementation, which is invoked when either the
> Devres instance goes out of scope or the devres callback leads to the
> resource being revoked, which implies a call to drop_in_place().
> 
> Co-developed-by: Philipp Stanner <pstanner@...hat.com>
> Signed-off-by: Philipp Stanner <pstanner@...hat.com>
> Signed-off-by: Danilo Krummrich <dakr@...hat.com>

...

> +impl<T> Devres<T> {
> +    /// Creates a new [`Devres`] instance of the give data.

Typo? give -> given

> +    pub fn new(dev: ARef<Device>, data: T, flags: Flags) -> Result<Self> {
> +        let callback = devres_callback::<T>;
> +
> +        let inner = Box::pin_init(
> +            pin_init!( DevresInner {
> +                dev: dev,
> +                data <- Revocable::new(data),
> +            }),
> +            flags,
> +        )?;
> +
> +        let ret = unsafe {
> +            bindings::devm_add_action(inner.dev.as_raw(), Some(callback), inner.as_cptr())
> +        };
> +
> +        if ret != 0 {
> +            return Err(Error::from_errno(ret));
> +        }
> +
> +        // We have to store the exact callback function pointer used with
> +        // `bindings::devm_add_action` for `bindings::devm_remove_action`. There compiler might put

Missing 'the'? "There *the* compiler might put ..."

Best regards

Dirk


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ