public inbox for linux-next@vger.kernel.org 
 help / color / mirror / Atom feed
* linux-next: manual merge of the rust-pin-init tree with Linus' tree
@ 2025-09-12  3:51 Stephen Rothwell
  2025-09-12  7:58 ` Danilo Krummrich
  0 siblings, 1 reply; 2+ messages in thread
From: Stephen Rothwell @ 2025-09-12  3:51 UTC (permalink / raw)
  To: Benno Lossin
  Cc: Danilo Krummrich, Linux Kernel Mailing List,
	Linux Next Mailing List

[-- Attachment #1: Type: text/plain, Size: 2993 bytes --]

Hi all,

Today's linux-next merge of the rust-pin-init tree got a conflict in:

  rust/kernel/devres.rs

between commit:

  75a7b151e808 ("rust: devres: fix leaking call to devm_add_action()")

from Linus' tree and commit:

  42415d163e5d ("rust: pin-init: add references to previously initialized fields")

from the rust-pin-init tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc rust/kernel/devres.rs
index 132545962218,91dbf3f4b166..000000000000
--- a/rust/kernel/devres.rs
+++ b/rust/kernel/devres.rs
@@@ -135,21 -134,11 +135,19 @@@ impl<T: Send> Devres<T> 
          T: 'a,
          Error: From<E>,
      {
-         let callback = Self::devres_callback;
- 
          try_pin_init!(&this in Self {
              dev: dev.into(),
-             callback,
+             callback: Self::devres_callback,
              // INVARIANT: `inner` is properly initialized.
 -            inner <- {
 +            inner <- Opaque::pin_init(try_pin_init!(Inner {
 +                    devm <- Completion::new(),
 +                    revoke <- Completion::new(),
 +                    data <- Revocable::new(data),
 +            })),
 +            // TODO: Replace with "initializer code blocks" [1] once available.
 +            //
 +            // [1] https://github.com/Rust-for-Linux/pin-init/pull/69
 +            _add_action: {
                  // SAFETY: `this` is a valid pointer to uninitialized memory.
                  let inner = unsafe { &raw mut (*this.as_ptr()).inner };
  
@@@ -160,14 -149,14 +158,14 @@@
                  //    properly initialized, because we require `dev` (i.e. the *bound* device) to
                  //    live at least as long as the returned `impl PinInit<Self, Error>`.
                  to_result(unsafe {
-                     bindings::devm_add_action(dev.as_raw(), Some(callback), inner.cast())
+                     bindings::devm_add_action(dev.as_raw(), Some(*callback), inner.cast())
 -                })?;
 +                }).inspect_err(|_| {
 +                    let inner = Opaque::cast_into(inner);
  
 -                Opaque::pin_init(try_pin_init!(Inner {
 -                    devm <- Completion::new(),
 -                    revoke <- Completion::new(),
 -                    data <- Revocable::new(data),
 -                }))
 +                    // SAFETY: `inner` is a valid pointer to an `Inner<T>` and valid for both reads
 +                    // and writes.
 +                    unsafe { core::ptr::drop_in_place(inner) };
 +                })?;
              },
          })
      }

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: linux-next: manual merge of the rust-pin-init tree with Linus' tree
  2025-09-12  3:51 linux-next: manual merge of the rust-pin-init tree with Linus' tree Stephen Rothwell
@ 2025-09-12  7:58 ` Danilo Krummrich
  0 siblings, 0 replies; 2+ messages in thread
From: Danilo Krummrich @ 2025-09-12  7:58 UTC (permalink / raw)
  To: Stephen Rothwell
  Cc: Benno Lossin, Linux Kernel Mailing List, Linux Next Mailing List

On 9/12/25 5:51 AM, Stephen Rothwell wrote:
> diff --cc rust/kernel/devres.rs
> index 132545962218,91dbf3f4b166..000000000000
> --- a/rust/kernel/devres.rs
> +++ b/rust/kernel/devres.rs
> @@@ -135,21 -134,11 +135,19 @@@ impl<T: Send> Devres<T> 
>           T: 'a,
>           Error: From<E>,
>       {
> -         let callback = Self::devres_callback;
> - 
>           try_pin_init!(&this in Self {
>               dev: dev.into(),
> -             callback,
> +             callback: Self::devres_callback,
>               // INVARIANT: `inner` is properly initialized.
>  -            inner <- {
>  +            inner <- Opaque::pin_init(try_pin_init!(Inner {
>  +                    devm <- Completion::new(),
>  +                    revoke <- Completion::new(),
>  +                    data <- Revocable::new(data),
>  +            })),
>  +            // TODO: Replace with "initializer code blocks" [1] once available.
>  +            //
>  +            // [1] https://github.com/Rust-for-Linux/pin-init/pull/69
>  +            _add_action: {
>                   // SAFETY: `this` is a valid pointer to uninitialized memory.
>                   let inner = unsafe { &raw mut (*this.as_ptr()).inner };
>   
> @@@ -160,14 -149,14 +158,14 @@@
>                   //    properly initialized, because we require `dev` (i.e. the *bound* device) to
>                   //    live at least as long as the returned `impl PinInit<Self, Error>`.
>                   to_result(unsafe {
> -                     bindings::devm_add_action(dev.as_raw(), Some(callback), inner.cast())
> +                     bindings::devm_add_action(dev.as_raw(), Some(*callback), inner.cast())
>  -                })?;
>  +                }).inspect_err(|_| {
>  +                    let inner = Opaque::cast_into(inner);
>   
>  -                Opaque::pin_init(try_pin_init!(Inner {
>  -                    devm <- Completion::new(),
>  -                    revoke <- Completion::new(),
>  -                    data <- Revocable::new(data),
>  -                }))
>  +                    // SAFETY: `inner` is a valid pointer to an `Inner<T>` and valid for both reads
>  +                    // and writes.
>  +                    unsafe { core::ptr::drop_in_place(inner) };
>  +                })?;
>               },
>           })
>       }

Looks good, thanks!

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-09-12  7:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-12  3:51 linux-next: manual merge of the rust-pin-init tree with Linus' tree Stephen Rothwell
2025-09-12  7:58 ` Danilo Krummrich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox