Re: [PATCH v10 8/9] platform/chrome: Protect cros_ec_device lifecycle with revocable

From: Laurent Pinchart

Date: Tue May 12 2026 - 04:38:25 EST


On Fri, May 08, 2026 at 08:53:09AM -0300, Jason Gunthorpe wrote:
> On Fri, May 08, 2026 at 06:54:47PM +0800, Tzung-Bi Shih wrote:
> > struct cros_ec_device *cros_ec_device_alloc(struct device *dev)
> > @@ -47,6 +49,15 @@ struct cros_ec_device *cros_ec_device_alloc(struct device *dev)
> > if (!ec_dev)
> > return NULL;
> >
> > + ec_dev->its_rev = revocable_alloc(ec_dev);
> > + if (!ec_dev->its_rev)
> > + return NULL;
> > + /*
> > + * Drop the extra reference for the caller as the caller is the
> > + * resource provider.
> > + */
> > + revocable_put(ec_dev->its_rev);
> > +
> > ec_dev->din_size = sizeof(struct ec_host_response) +
> > sizeof(struct ec_response_get_protocol_info) +
> > EC_MAX_RESPONSE_OVERHEAD;
>
> FWIW I am still very much against seeing any revokable concept used
> *between two drivers*. That will turn the kernel's lifetime model into
> spaghetti code.

I agree, I really think it will become a huge mess that we will
massively regret.

/me feels like Cassandra

> Your other series where you only have to change
> drivers/platform/chrome/cros_ec_chardev.c just confirms how wrong this
> approach is.
>
> Given you say this is such a bug I think you really should be sending
> a series that is patches 5 through 7 from the other series and a
> simple rwsem instead of misc_deregister_sync() to deal with this bug
> ASAP. No need to complicate a simple bug fix in a driver with all
> these core changes.
>
> Once the bug is fixed you can continue to try to propose more general
> solutions.

--
Regards,

Laurent Pinchart