Re: [PATCH v2 1/5] iio: core: move to cleanup.h magic

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

 



On Sun, 2024-02-25 at 12:36 +0000, Jonathan Cameron wrote:
> On Fri, 23 Feb 2024 13:43:44 +0100
> Nuno Sa <nuno.sa@xxxxxxxxxx> wrote:
> 
> > Use the new cleanup magic for handling mutexes in IIO. This allows us to
> > greatly simplify some code paths.
> > 
> > Note that we keep the plain mutex calls in the
> > iio_device_release|acquire() APIs since in there the macros would likely
> > not help much (as we want to keep the lock acquired when he leave the
> > APIs).
> > 
> > Signed-off-by: Nuno Sa <nuno.sa@xxxxxxxxxx>
> > ---
> 
> 
> > @@ -1808,29 +1805,22 @@ static long iio_ioctl(struct file *filp, unsigned int
> > cmd, unsigned long arg)
> >  	struct iio_ioctl_handler *h;
> >  	int ret = -ENODEV;
> >  
> > -	mutex_lock(&iio_dev_opaque->info_exist_lock);
> > -
> > +	guard(mutex)(&iio_dev_opaque->info_exist_lock);
> >  	/*
> >  	 * The NULL check here is required to prevent crashing when a device
> >  	 * is being removed while userspace would still have open file handles
> >  	 * to try to access this device.
> >  	 */
> >  	if (!indio_dev->info)
> > -		goto out_unlock;
> > +		return ret;
> 
> return -ENODEV; and drop initialisation above.

Ok, that was actually what I had. Ended up changing it because of the slightly
smaller diff on the patch.

- Nuno Sá






[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux