Messages in this thread | | | Date | Wed, 30 Nov 2022 14:31:48 +0200 | From | Andy Shevchenko <> | Subject | Re: [PATCH v4 2/2] gpiolib: protect the GPIO device against being dropped while in use by user-space |
| |
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@linux.intel.com> 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
| |