Re: [PATCH v5] gpio: consumer: new virtual driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxx> 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@xxxxxxxxxxxxxxx> 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





[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux