Re: [PATCH] rust: devres: require T: Send for Devres

From: Benno Lossin
Date: Thu Jun 26 2025 - 09:45:58 EST


On Thu Jun 26, 2025 at 3:24 PM CEST, Danilo Krummrich wrote:
> Due to calling Revocable::revoke() from Devres::devres_callback() T may
> be dropped from Devres::devres_callback() and hence must be Send.
>
> Fix this by adding the corresponding bound to Devres and DevresInner.
>
> Reported-by: Boqun Feng <boqun.feng@xxxxxxxxx>
> Closes: https://lore.kernel.org/lkml/aFzI5L__OcB9hqdG@xxxxxxxx/
> Fixes: 76c01ded724b ("rust: add devres abstraction")
> Signed-off-by: Danilo Krummrich <dakr@xxxxxxxxxx>
> ---
> rust/kernel/devres.rs | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)

It would be enough to require `Send` on all `impl` blocks and not on the
struct itself. Normally, I recommend doing that, because then you can
have types like `Foo<Invalid>` existing when they come up in some weird
type. But in this case, I think it's fine to add it to the type
definition.

Reviewed-by: Benno Lossin <lossin@xxxxxxxxxx>

---
Cheers,
Benno