linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
Cc: Hartmut Knaack <knaack.h@gmx.de>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	Sanchayan Maity <maitysanchayan@gmail.com>,
	Gregor Boirie <gregor.boirie@parrot.com>,
	Matt Ranostay <mranostay@gmail.com>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	Chris Healy <Chris.Healy@zii.aero>,
	Jeff White <Jeff.White@zii.aero>,
	Vladimir Barinov <vladimir.barinov@cogentembedded.com>
Subject: Re: [PATCH] iio: hi8435: fix race between event enable and event generation
Date: Wed, 24 May 2017 20:30:33 +0100	[thread overview]
Message-ID: <20170524203033.558a09f9@kernel.org> (raw)
In-Reply-To: <20170523080729.20459-1-nikita.yoush@cogentembedded.com>

On Tue, 23 May 2017 11:07:29 +0300
Nikita Yushchenko <nikita.yoush@cogentembedded.com> wrote:

> Add locking to avoid interference between reading/processing current
> sence in event enable and event generation paths.
> 
> Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
Make sense.  Could you give a little more detail on the seriousness
of this bug?  I need to assess whether we just queue it up for the
next merge window or push it forward quicker as a bug fix and
whether to mark it for stable or not.

You probably have a better idea of how much it matters than I do!

Thanks,

Jonathan
> ---
>  drivers/iio/adc/hi8435.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/iio/adc/hi8435.c b/drivers/iio/adc/hi8435.c
> index ab59969b7c49..28fc699f00f6 100644
> --- a/drivers/iio/adc/hi8435.c
> +++ b/drivers/iio/adc/hi8435.c
> @@ -144,6 +144,8 @@ static int hi8435_write_event_config(struct iio_dev *idev,
>  	int ret;
>  	u32 tmp;
>  
> +	mutex_lock(&priv->lock);
> +
>  	if (state) {
>  		ret = hi8435_readl(priv, HI8435_SO31_0_REG, &tmp);
>  		if (ret < 0)
> @@ -157,6 +159,8 @@ static int hi8435_write_event_config(struct iio_dev *idev,
>  	} else
>  		priv->event_scan_mask &= ~BIT(chan->channel);
>  
> +	mutex_unlock(&priv->lock);
> +
>  	return 0;
>  }
>  
> @@ -449,12 +453,16 @@ static irqreturn_t hi8435_trigger_handler(int irq, void *private)
>  	u32 val;
>  	int ret;
>  
> +	mutex_lock(&priv->lock);
> +
>  	ret = hi8435_readl(priv, HI8435_SO31_0_REG, &val);
>  	if (ret < 0)
>  		goto err_read;
>  
>  	hi8435_iio_push_event(idev, val);
>  
> +	mutex_unlock(&priv->lock);
> +
>  err_read:
>  	iio_trigger_notify_done(idev->trig);
>  

  reply	other threads:[~2017-05-24 19:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-23  8:07 [PATCH] iio: hi8435: fix race between event enable and event generation Nikita Yushchenko
2017-05-24 19:30 ` Jonathan Cameron [this message]
2017-05-24 19:56   ` Nikita Yushchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170524203033.558a09f9@kernel.org \
    --to=jic23@kernel.org \
    --cc=Chris.Healy@zii.aero \
    --cc=Jeff.White@zii.aero \
    --cc=gregor.boirie@parrot.com \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maitysanchayan@gmail.com \
    --cc=mranostay@gmail.com \
    --cc=nikita.yoush@cogentembedded.com \
    --cc=pmeerw@pmeerw.net \
    --cc=vladimir.barinov@cogentembedded.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).