Re: [PATCH 3/3] rust: devres: fix race in Devres::drop()

From: Boqun Feng
Date: Thu Jun 12 2025 - 11:57:46 EST


On Thu, Jun 12, 2025 at 05:44:27PM +0200, Danilo Krummrich wrote:
> On Thu, Jun 12, 2025 at 08:24:57AM -0700, Boqun Feng wrote:
> > Thanks for the explanation, and sorry I'm a bit late for the response. I
> > was trying to find a place that we should document this, how about the
> > diff below:
> >
> > ------------
> > diff --git a/rust/kernel/devres.rs b/rust/kernel/devres.rs
> > index 0f79a2ec9474..c8b9754e411b 100644
> > --- a/rust/kernel/devres.rs
> > +++ b/rust/kernel/devres.rs
> > @@ -31,7 +31,8 @@ struct DevresInner<T> {
> > /// manage their lifetime.
> > ///
> > /// [`Device`] bound resources should be freed when either the resource goes out of scope or the
> > -/// [`Device`] is unbound respectively, depending on what happens first.
> > +/// [`Device`] is unbound respectively, depending on what happens first. And if the resource goes
> > +/// out of scope first, [`Device`] unbinding will wait until the resource being freed.
>
> I will add
>
> In any case, it is always guaranteed that revoking the device resource
> is completed before the corresponding [`Device`] is unbound.
>
> when applying the patch, if that's fine with you.

Looks good to me, thanks!

Regards,
Boqun