Messages in this thread | | | Date | Thu, 17 Aug 2023 16:00:53 +0300 | From | Andy Shevchenko <> | Subject | Re: [PATCH v5] gpio: consumer: new virtual driver |
| |
On Thu, Aug 17, 2023 at 02:53:04PM +0200, Bartosz Golaszewski wrote: > On Thu, Aug 17, 2023 at 2:38 PM Andy Shevchenko > <andriy.shevchenko@linux.intel.com> wrote: > > On Thu, Aug 17, 2023 at 02:14:04PM +0200, Bartosz Golaszewski wrote: > > > On Thu, Aug 17, 2023 at 12:03 PM Andy Shevchenko > > > <andriy.shevchenko@linux.intel.com> wrote: > > > > On Tue, Aug 15, 2023 at 08:56:50PM +0200, Bartosz Golaszewski wrote:
...
> > > > > + struct gpio_consumer_device *dev = lookup->parent; > > > > > + > > > > > + guard(mutex)(&dev->lock); > > > > > + > > > > > + return sprintf(page, "%s\n", lookup->key); > > > > (1)
...
> > So the 1) has to be amended then. > > No! lookup->key is a string stored in the lookup struct BUT protected > by the consumer device's lock (it must be or else the lookup could get > removed while it's being modified). Unless you want to duplicate the > string in order to release the mutex earlier, it has to be locked > until sprintf() returns.
Ah, good point, otherwise we would need a copy...
-- With Best Regards, Andy Shevchenko
| |