Linux driver-core infrastructure
 help / color / mirror / Atom feed
* Re: [PATCH 6.18 445/583] rust: devres: fix race condition due to nesting
       [not found] <20260909134253.387396612@linuxfoundation.org>
@ 2026-09-10  1:03 ` Miguel Ojeda
  2026-09-10 13:40   ` Sasha Levin
  0 siblings, 1 reply; 2+ messages in thread
From: Miguel Ojeda @ 2026-09-10  1:03 UTC (permalink / raw)
  To: gregkh
  Cc: aliceryhl, boris.brezillon, dakr, markus.probst, patches, sashal,
	stable, Rafael J. Wysocki, driver-core

On Wed, 09 Sep 2026 15:42:10 +0200 Greg Kroah-Hartman <gregkh@linuxfoundation.org> wrote:
>
> -        try_pin_init!(&this in Self {
> +        let callback = Self::devres_callback;
> +        let inner = Arc::pin_init(
> +            try_pin_init!(Inner {
> +                data <- Revocable::new(data),
> +            }),
> +            GFP_KERNEL,
> +        )?;
> +        let devres_inner = inner.clone();

The compiler complains here:

    error[E0277]: the trait bound `impl pin_init::PinInit<Inner<T>, error::Error>: pin_init::PinInit<_, E>` is not satisfied
       --> rust/kernel/devres.rs:141:13
        |
    140 |           let inner = Arc::pin_init(
        |                       ------------- required by a bound introduced by this call
    141 | /             try_pin_init!(Inner {
    142 | |                 data <- Revocable::new(data),
    143 | |                 revocation <- Completion::new(),
    144 | |             }),
        | |              ^
        | |              |
        | |______________the trait `pin_init::PinInit<_, E>` is not implemented for `impl pin_init::PinInit<Inner<T>, error::Error>`
        |                this tail expression is of type `impl PinInit<Inner<T>, Error>`
        |
        = help: the following other types implement trait `pin_init::PinInit<T, E>`:
                  <AlwaysFail<T> as pin_init::PinInit<T, ()>>
                  <ChainPinInit<I, F, T, E> as pin_init::PinInit<T, E>>
                  <ChainInit<I, F, T, E> as pin_init::PinInit<T, E>>
                  <core::result::Result<T, E> as pin_init::PinInit<T, E>>
    note: required by a bound in `init::InPlaceInit::pin_init`
       --> rust/kernel/init.rs:155:31
        |
    155 |     fn pin_init<E>(init: impl PinInit<T, E>, flags: Flags) -> error::Result<Self::PinnedSelf>
        |                               ^^^^^^^^^^^^^ required by this bound in `InPlaceInit::pin_init`

    error[E0282]: type annotations needed for `Arc<T>`
       --> rust/kernel/devres.rs:140:13
        |
    140 |         let inner = Arc::pin_init(
        |             ^^^^^
    ...
    147 |         let devres_inner = inner.clone();
        |                                  ----- type must be known at this point
        |
    help: consider giving `inner` an explicit type, where the type for type parameter `T` is specified
        |
    140 |         let inner: Arc<T> = Arc::pin_init(
        |                  ++++++++

    error[E0282]: type annotations needed
       --> rust/kernel/devres.rs:158:17
        |
    158 |                 Arc::as_ptr(&inner).cast_mut().cast(),
        |                 ^^^^^^^^^^^         -------- type must be known at this point
        |                 |
        |                 cannot infer type of the type parameter `T` declared on the struct `Arc`
        |
    help: consider specifying the generic argument
        |
    158 |                 Arc::<T>::as_ptr(&inner).cast_mut().cast(),
        |                    +++++

This diff would work, similar to commit 9aa64d2503c6 ("rust: devres:
embed struct devres_node directly"), but I wonder if the sequence of
backports was not intended like this:

    diff --git a/rust/kernel/devres.rs b/rust/kernel/devres.rs
    index 67471946f2b5..0cafe7ba28c8 100644
    --- a/rust/kernel/devres.rs
    +++ b/rust/kernel/devres.rs
    @@ -137,7 +137,7 @@ pub fn new<E>(dev: &Device<Bound>, data: impl PinInit<T, E>) -> Result<Self>
             Error: From<E>,
         {
             let callback = Self::devres_callback;
    -        let inner = Arc::pin_init(
    +        let inner = Arc::pin_init::<Error>(
                 try_pin_init!(Inner {
                     data <- Revocable::new(data),
                     revocation <- Completion::new(),

I hope that helps!

Cc: Markus Probst <markus.probst@posteo.de>
Cc: Sasha Levin <sashal@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Alice Ryhl <aliceryhl@google.com>
Cc: Boris Brezillon <boris.brezillon@collabora.com>
Cc: Danilo Krummrich <dakr@kernel.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: driver-core@lists.linux.dev

Cheers,
Miguel

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

* Re: [PATCH 6.18 445/583] rust: devres: fix race condition due to nesting
  2026-09-10  1:03 ` [PATCH 6.18 445/583] rust: devres: fix race condition due to nesting Miguel Ojeda
@ 2026-09-10 13:40   ` Sasha Levin
  0 siblings, 0 replies; 2+ messages in thread
From: Sasha Levin @ 2026-09-10 13:40 UTC (permalink / raw)
  To: gregkh
  Cc: Sasha Levin, aliceryhl, boris.brezillon, dakr, markus.probst,
	patches, stable, Rafael J. Wysocki, driver-core, Miguel Ojeda

> The compiler complains here:
>
>     error[E0277]: the trait bound `impl pin_init::PinInit
> [...]

Dropped both offending commits from 6.18, thanks!

-- 
Thanks,
Sasha

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

end of thread, other threads:[~2026-09-10 13:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20260909134253.387396612@linuxfoundation.org>
2026-09-10  1:03 ` [PATCH 6.18 445/583] rust: devres: fix race condition due to nesting Miguel Ojeda
2026-09-10 13:40   ` Sasha Levin

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