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: <20260122191252.320750d4@jic23-huawei>
Date: Thu, 22 Jan 2026 19:12:52 +0000
From: Jonathan Cameron <jic23@...nel.org>
To: Kurt Borja <kuurtb@...il.com>
Cc: Andy Shevchenko <andriy.shevchenko@...el.com>, Lars-Peter Clausen
 <lars@...afoo.de>, Michael Hennerich <Michael.Hennerich@...log.com>, Benson
 Leung <bleung@...omium.org>, Antoniu Miclaus <antoniu.miclaus@...log.com>,
 Gwendal Grignou <gwendal@...omium.org>, Shrikant Raskar
 <raskar.shree97@...il.com>, Per-Daniel Olsson <perdaniel.olsson@...s.com>,
 David Lechner <dlechner@...libre.com>, Nuno Sá
 <nuno.sa@...log.com>, Andy Shevchenko <andy@...nel.org>, Guenter Roeck
 <groeck@...omium.org>, Jonathan Cameron <Jonathan.Cameron@...wei.com>,
 linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org,
 chrome-platform@...ts.linux.dev
Subject: Re: [PATCH v5 5/7] iio: light: vcnl4000: Use IIO cleanup helpers

On Tue, 20 Jan 2026 01:20:45 -0500
Kurt Borja <kuurtb@...il.com> wrote:

> Use IIO_DEV_ACQUIRE_DIRECT_MODE() helper to automatically release direct
> mode.
> 
> Reviewed-by: David Lechner <dlechner@...libre.com>
> Reviewed-by: Nuno Sá <nuno.sa@...log.com>
> Signed-off-by: Kurt Borja <kuurtb@...il.com>
Given sparse doesn't play well with this stuff, this is (I think) more or less expected.
drivers/iio/light/vcnl4000.c: note: in included file (through include/linux/iio/buffer.h):                                                                          
./include/linux/iio/iio.h:687:20: warning: context imbalance in 'vcnl4010_read_raw' - different lock contexts for basic block                                       
./include/linux/iio/iio.h:687:20: warning: context imbalance in 'vcnl4010_write_raw' - different lock contexts for basic block                                      
./include/linux/iio/iio.h:687:20: warning: context imbalance in 'vcnl4010_config_threshold' - different lock contexts for basic block   

Hopefully it will one day catch up or we'll move to an alternative for lock checking.

J
> ---
>  drivers/iio/light/vcnl4000.c | 49 ++++++++++++++++----------------------------
>  1 file changed, 18 insertions(+), 31 deletions(-)
> 
> diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c
> index 4dbb2294a843..a36c23813679 100644
> --- a/drivers/iio/light/vcnl4000.c
> +++ b/drivers/iio/light/vcnl4000.c
> @@ -1078,20 +1078,17 @@ static int vcnl4010_read_raw(struct iio_dev *indio_dev,
>  
>  	switch (mask) {
>  	case IIO_CHAN_INFO_RAW:
> -	case IIO_CHAN_INFO_SCALE:
> -		if (!iio_device_claim_direct(indio_dev))
> +	case IIO_CHAN_INFO_SCALE: {
> +		IIO_DEV_ACQUIRE_DIRECT_MODE(indio_dev, claim);
> +		if (IIO_DEV_ACQUIRE_FAILED(claim))
>  			return -EBUSY;
>  
>  		/* Protect against event capture. */
> -		if (vcnl4010_is_in_periodic_mode(data)) {
> -			ret = -EBUSY;
> -		} else {
> -			ret = vcnl4000_read_raw(indio_dev, chan, val, val2,
> -						mask);
> -		}
> +		if (vcnl4010_is_in_periodic_mode(data))
> +			return -EBUSY;
>  
> -		iio_device_release_direct(indio_dev);
> -		return ret;
> +		return vcnl4000_read_raw(indio_dev, chan, val, val2, mask);
> +	}
>  	case IIO_CHAN_INFO_SAMP_FREQ:
>  		switch (chan->type) {
>  		case IIO_PROXIMITY:
> @@ -1148,36 +1145,27 @@ static int vcnl4010_write_raw(struct iio_dev *indio_dev,
>  			      struct iio_chan_spec const *chan,
>  			      int val, int val2, long mask)
>  {
> -	int ret;
>  	struct vcnl4000_data *data = iio_priv(indio_dev);
>  
> -	if (!iio_device_claim_direct(indio_dev))
> +	IIO_DEV_ACQUIRE_DIRECT_MODE(indio_dev, claim);
> +	if (IIO_DEV_ACQUIRE_FAILED(claim))
>  		return -EBUSY;
>  
>  	/* Protect against event capture. */
> -	if (vcnl4010_is_in_periodic_mode(data)) {
> -		ret = -EBUSY;
> -		goto end;
> -	}
> +	if (vcnl4010_is_in_periodic_mode(data))
> +		return -EBUSY;
>  
>  	switch (mask) {
>  	case IIO_CHAN_INFO_SAMP_FREQ:
>  		switch (chan->type) {
>  		case IIO_PROXIMITY:
> -			ret = vcnl4010_write_proxy_samp_freq(data, val, val2);
> -			goto end;
> +			return vcnl4010_write_proxy_samp_freq(data, val, val2);
>  		default:
> -			ret = -EINVAL;
> -			goto end;
> +			return -EINVAL;
>  		}
>  	default:
> -		ret = -EINVAL;
> -		goto end;
> +		return -EINVAL;
>  	}
> -
> -end:
> -	iio_device_release_direct(indio_dev);
> -	return ret;
>  }
>  
>  static int vcnl4010_read_event(struct iio_dev *indio_dev,
> @@ -1438,14 +1426,13 @@ static int vcnl4010_config_threshold_disable(struct vcnl4000_data *data)
>  static int vcnl4010_config_threshold(struct iio_dev *indio_dev, bool state)
>  {
>  	struct vcnl4000_data *data = iio_priv(indio_dev);
> -	int ret;
>  
>  	if (state) {
> -		if (!iio_device_claim_direct(indio_dev))
> +		IIO_DEV_ACQUIRE_DIRECT_MODE(indio_dev, claim);
> +		if (IIO_DEV_ACQUIRE_FAILED(claim))
>  			return -EBUSY;
> -		ret = vcnl4010_config_threshold_enable(data);
> -		iio_device_release_direct(indio_dev);
> -		return ret;
> +
> +		return vcnl4010_config_threshold_enable(data);
>  	} else {
>  		return vcnl4010_config_threshold_disable(data);
>  	}
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ