Re: [PATCH v4 2/2] gpiolib: protect the GPIO device against being dropped while in use by user-space

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

 



On Wed, Nov 30, 2022 at 01:05:30PM +0100, Bartosz Golaszewski wrote:
> On Wed, Nov 30, 2022 at 1:02 PM Andy Shevchenko
> <andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
> > On Wed, Nov 30, 2022 at 10:05:56AM +0100, Bartosz Golaszewski wrote:

> > > +     down_read(&gdev->sem);
> >
> > Thinking more about this, wouldn't be better to actually
> >
> >         ret = down_read_trylock(&gdev->sem);
> >         if (ret)
> >                 return ret;
> >
> > ?
> 
> You mean as in: try to take the lock, but if we're already removing
> the device (as the down_write() can only happen in gpiochip_remove()),
> then die right away? Smart! Yeah, I'll do it this way.

But please check return values properly (it seems not obvious what it does
return).

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