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] [day] [month] [year] [list]
Message-ID: <20210221163902.617ee71d@archlinux>
Date:   Sun, 21 Feb 2021 16:39:02 +0000
From:   Jonathan Cameron <jic23@...nel.org>
To:     Mircea Caprioru <mircea.caprioru@...log.com>
Cc:     <Michael.Hennerich@...log.com>, <alexandru.ardelean@...log.com>,
        <lars@...afoo.de>, <gregkh@...uxfoundation.org>,
        <linux-kernel@...r.kernel.org>, <linux-iio@...r.kernel.org>,
        Sergiu Cuciurean <sergiu.cuciurean@...log.com>
Subject: Re: [PATCH 3/5] iio: adc: npcm_adc: Replace indio_dev->mlock with
 own device lock

On Mon, 28 Sep 2020 16:13:31 +0300
Mircea Caprioru <mircea.caprioru@...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 on the device's state structure.
> 
> This is part of a bigger cleanup.
> Link: https://lore.kernel.org/linux-iio/CA+U=Dsoo6YABe5ODLp+eFNPGFDjk5ZeQEceGkqjxXcVEhLWubw@mail.gmail.com/
> 
> Signed-off-by: Sergiu Cuciurean <sergiu.cuciurean@...log.com>
> Signed-off-by: Mircea Caprioru <mircea.caprioru@...log.com>
Applied,

thanks,

Jonathan

> ---
>  drivers/iio/adc/npcm_adc.c | 15 +++++++++++++--
>  1 file changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/adc/npcm_adc.c b/drivers/iio/adc/npcm_adc.c
> index d9d105920001..f7bc0bb7f112 100644
> --- a/drivers/iio/adc/npcm_adc.c
> +++ b/drivers/iio/adc/npcm_adc.c
> @@ -25,6 +25,15 @@ struct npcm_adc {
>  	wait_queue_head_t wq;
>  	struct regulator *vref;
>  	struct reset_control *reset;
> +	/*
> +	 * Lock to protect the device state during a potential concurrent
> +	 * read access from userspace. Reading a raw value requires a sequence
> +	 * of register writes, then a wait for a event and finally a register
> +	 * read, during which userspace could issue another read request.
> +	 * This lock protects a read access from ocurring before another one
> +	 * has finished.
> +	 */
> +	struct mutex lock;
>  };
>  
>  /* ADC registers */
> @@ -135,9 +144,9 @@ static int npcm_adc_read_raw(struct iio_dev *indio_dev,
>  
>  	switch (mask) {
>  	case IIO_CHAN_INFO_RAW:
> -		mutex_lock(&indio_dev->mlock);
> +		mutex_lock(&info->lock);
>  		ret = npcm_adc_read(info, val, chan->channel);
> -		mutex_unlock(&indio_dev->mlock);
> +		mutex_unlock(&info->lock);
>  		if (ret) {
>  			dev_err(info->dev, "NPCM ADC read failed\n");
>  			return ret;
> @@ -187,6 +196,8 @@ static int npcm_adc_probe(struct platform_device *pdev)
>  		return -ENOMEM;
>  	info = iio_priv(indio_dev);
>  
> +	mutex_init(&info->lock);
> +
>  	info->dev = &pdev->dev;
>  
>  	info->regs = devm_platform_ioremap_resource(pdev, 0);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ