Re: [PATCH v11 4/5] platform/chrome: Protect cros_ec_device lifecycle with revocable

From: Tzung-Bi Shih

Date: Wed May 13 2026 - 23:34:26 EST


On Wed, May 13, 2026 at 08:51:02AM -0300, Jason Gunthorpe wrote:
> On Wed, May 13, 2026 at 05:10:42PM +0800, Tzung-Bi Shih wrote:
> > The cros_ec_device can be unregistered when the underlying device is
> > removed. Other kernel drivers that interact with the EC may hold a
> > pointer to the cros_ec_device, creating a risk of a use-after-free
> > error if the EC device is removed while still being referenced.
> >
> > To prevent this, leverage the revocable and convert the underlying
> > device drivers to resource providers of cros_ec_device.
> >
> > ---
> > v11:
> > - No changes.
>
> Two people are opposing this and yet no changes? Why haven't you
> followed my advice to fix the bug in this driver in the obvious way?

I understand there's opposition to this approach for this specific driver.
The main goal of the series is to introduce the revocable APIs and show
potential use cases. I used this patch to illustrate how revocable could
solve this class of problem, not necessarily as the definitive fix in this
instance.

To help me understand, could you elaborate on why the revocable mechanism
isn't suitable here? I'm wondering because if this piece of code were to
transition to Rust in the future, would the concerns you have also apply
to using Revocable[1] in the Rust context for this driver?

[1] https://rust.docs.kernel.org/kernel/revocable/struct.Revocable.html