lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z4MMMThN0qxIrA6o@JSANTO12-L01.ad.analog.com>
Date: Sat, 11 Jan 2025 21:26:25 -0300
From: Jonathan Santos <jonath4nns@...il.com>
To: David Lechner <dlechner@...libre.com>
Cc: Jonathan Santos <Jonathan.Santos@...log.com>, linux-iio@...r.kernel.org,
	devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
	lars@...afoo.de, Michael.Hennerich@...log.com, jic23@...nel.org,
	robh@...nel.org, krzk+dt@...nel.org, conor+dt@...nel.org,
	marcelo.schmitt1@...il.com
Subject: Re: [PATCH v1 08/15] iio: adc: ad7768-1: use guard(mutex) to
 simplify code

On 01/07, David Lechner wrote:
> On 1/7/25 9:25 AM, Jonathan Santos wrote:
> > Use guard(mutex) from cleanup.h to remove most of the gotos and to make
> > the code simpler and less likely to fail due to forgetting to unlock
> > the resources.
> > 
> > Signed-off-by: Jonathan Santos <Jonathan.Santos@...log.com>
> > ---
> 
> ...
> 
> > @@ -484,7 +477,7 @@ static irqreturn_t ad7768_trigger_handler(int irq, void *p)
> >  	struct ad7768_state *st = iio_priv(indio_dev);
> >  	int ret;
> >  
> > -	mutex_lock(&st->lock);
> > +	guard(mutex)(&st->lock);
> >  
> >  	ret = spi_read(st->spi, &st->data.scan.chan, 3);
> >  	if (ret < 0)
> > @@ -495,7 +488,6 @@ static irqreturn_t ad7768_trigger_handler(int irq, void *p)
> >  
> >  err_unlock:
> 
> nit: also rename the label since it is no longer unlocking
> 
> >  	iio_trigger_notify_done(indio_dev->trig);
> > -	mutex_unlock(&st->lock);
> >  
> >  	return IRQ_HANDLED;
> >  }
> 
> I'm also wondering if we should just drop this lock. It is only protecting
> a triggered buffer SPI xfer and debugfs register access from happening at the
> same time.
> 
> Since we have to write a magic value to exit conversion mode, reading registers
> during a buffered read is going to cause problems anyway. So we could just
> remove the mutex lock and use iio_device_claim_direct_mode() instead in
> ad7768_reg_access().
>
Ok, that makes sense. I will change in the next version.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ