driver-core.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Miguel Ojeda <ojeda@kernel.org>
To: gregkh@linuxfoundation.org
Cc: aliceryhl@google.com, boris.brezillon@collabora.com,
	dakr@kernel.org, markus.probst@posteo.de,
	patches@lists.linux.dev, sashal@kernel.org,
	stable@vger.kernel.org, "Rafael J. Wysocki" <rafael@kernel.org>,
	driver-core@lists.linux.dev
Subject: Re: [PATCH 6.18 445/583] rust: devres: fix race condition due to nesting
Date: Thu, 10 Sep 2026 03:03:10 +0200	[thread overview]
Message-ID: <20260910010310.429807-1-ojeda@kernel.org> (raw)
In-Reply-To: <20260909134253.387396612@linuxfoundation.org>

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

       reply	other threads:[~2026-09-10  1:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260909134253.387396612@linuxfoundation.org>
2026-09-10  1:03 ` Miguel Ojeda [this message]
2026-09-10 13:40   ` [PATCH 6.18 445/583] rust: devres: fix race condition due to nesting Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260910010310.429807-1-ojeda@kernel.org \
    --to=ojeda@kernel.org \
    --cc=aliceryhl@google.com \
    --cc=boris.brezillon@collabora.com \
    --cc=dakr@kernel.org \
    --cc=driver-core@lists.linux.dev \
    --cc=gregkh@linuxfoundation.org \
    --cc=markus.probst@posteo.de \
    --cc=patches@lists.linux.dev \
    --cc=rafael@kernel.org \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).