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  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]
Date:   Sat, 29 Aug 2020 16:35:32 +0100
From:   Jonathan Cameron <jic23@...nel.org>
To:     Alexandru Ardelean <alexandru.ardelean@...log.com>
Cc:     <linux-iio@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
        <kgene@...nel.org>, <krzk@...nel.org>,
        "Sergiu Cuciurean" <sergiu.cuciurean@...log.com>
Subject: Re: [PATCH] iio: adc: exynos_adc: Replace indio_dev->mlock with own
 device lock

On Wed, 26 Aug 2020 16:22:03 +0300
Alexandru Ardelean <alexandru.ardelean@...log.com> wrote:

> From: Sergiu Cuciurean <sergiu.cuciurean@...log.com>
> 
> As part of the general cleanup of indio_dev->mlock, this change replaces
> it with a local lock, to protect potential concurrent access to the
> completion callback during a conversion.
> 
> Signed-off-by: Sergiu Cuciurean <sergiu.cuciurean@...log.com>
> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@...log.com>
Same comment as the other one about needing lock scope to be documented.

Otherwise looks good.  I thought we only had complicated uses of this
left, but clearly not :)

Jonathan

> ---
>  drivers/iio/adc/exynos_adc.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/adc/exynos_adc.c b/drivers/iio/adc/exynos_adc.c
> index 7d23b6c33284..6a49f8dfab22 100644
> --- a/drivers/iio/adc/exynos_adc.c
> +++ b/drivers/iio/adc/exynos_adc.c
> @@ -132,6 +132,8 @@ struct exynos_adc {
>  
>  	struct completion	completion;
>  
> +	struct mutex		lock;
> +
>  	u32			value;
>  	unsigned int            version;
>  
> @@ -542,7 +544,7 @@ static int exynos_read_raw(struct iio_dev *indio_dev,
>  		return -EINVAL;
>  	}
>  
> -	mutex_lock(&indio_dev->mlock);
> +	mutex_lock(&info->lock);
>  	reinit_completion(&info->completion);
>  
>  	/* Select the channel to be used and Trigger conversion */
> @@ -562,7 +564,7 @@ static int exynos_read_raw(struct iio_dev *indio_dev,
>  		ret = IIO_VAL_INT;
>  	}
>  
> -	mutex_unlock(&indio_dev->mlock);
> +	mutex_unlock(&info->lock);
>  
>  	return ret;
>  }
> @@ -573,7 +575,7 @@ static int exynos_read_s3c64xx_ts(struct iio_dev *indio_dev, int *x, int *y)
>  	unsigned long timeout;
>  	int ret;
>  
> -	mutex_lock(&indio_dev->mlock);
> +	mutex_lock(&info->lock);
>  	info->read_ts = true;
>  
>  	reinit_completion(&info->completion);
> @@ -598,7 +600,7 @@ static int exynos_read_s3c64xx_ts(struct iio_dev *indio_dev, int *x, int *y)
>  	}
>  
>  	info->read_ts = false;
> -	mutex_unlock(&indio_dev->mlock);
> +	mutex_unlock(&info->lock);
>  
>  	return ret;
>  }
> @@ -872,6 +874,8 @@ static int exynos_adc_probe(struct platform_device *pdev)
>  	indio_dev->channels = exynos_adc_iio_channels;
>  	indio_dev->num_channels = info->data->num_channels;
>  
> +	mutex_init(&info->lock);
> +
>  	ret = request_irq(info->irq, exynos_adc_isr,
>  					0, dev_name(&pdev->dev), info);
>  	if (ret < 0) {

Powered by blists - more mailing lists