linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Matt Ranostay <mranostay@gmail.com>, linux-iio@vger.kernel.org
Subject: Re: [PATCH v2 3/4] iio: chemical: vz89x: prevent corrupted buffer from being read
Date: Mon, 29 Aug 2016 18:01:14 +0100	[thread overview]
Message-ID: <1b1d4202-e3a4-dc38-2707-cb1a1aab543c@kernel.org> (raw)
In-Reply-To: <1472107490-11924-4-git-send-email-mranostay@gmail.com>

On 25/08/16 07:44, Matt Ranostay wrote:
> Signed-off-by: Matt Ranostay <mranostay@gmail.com>
Applied to the togreg branch of iio.git.
Initially pushed out as testing for the autobuilders to
play with it.

Thanks,

Jonathan
> ---
>  drivers/iio/chemical/vz89x.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/chemical/vz89x.c b/drivers/iio/chemical/vz89x.c
> index 289d2919deea..cd3870ead3fd 100644
> --- a/drivers/iio/chemical/vz89x.c
> +++ b/drivers/iio/chemical/vz89x.c
> @@ -55,6 +55,7 @@ struct vz89x_data {
>  	struct mutex lock;
>  	int (*xfer)(struct vz89x_data *data, u8 cmd);
>  
> +	bool is_valid;
>  	unsigned long last_update;
>  	u8 buffer[VZ89TE_REG_MEASUREMENT_RD_SIZE];
>  };
> @@ -229,7 +230,10 @@ static int vz89x_get_measurement(struct vz89x_data *data)
>  
>  	/* sensor can only be polled once a second max per datasheet */
>  	if (!time_after(jiffies, data->last_update + HZ))
> -		return 0;
> +		return data->is_valid ? 0 : -EAGAIN;
> +
> +	data->is_valid = false;
> +	data->last_update = jiffies;
>  
>  	ret = data->xfer(data, chip->cmd);
>  	if (ret < 0)
> @@ -239,7 +243,7 @@ static int vz89x_get_measurement(struct vz89x_data *data)
>  	if (ret)
>  		return -EAGAIN;
>  
> -	data->last_update = jiffies;
> +	data->is_valid = true;
>  
>  	return 0;
>  }
> 


  reply	other threads:[~2016-08-29 17:01 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-25  6:44 [PATCH v2 0/4] iio: chemical: vz89x: add multiple chip functionality Matt Ranostay
2016-08-25  6:44 ` [PATCH v2 1/4] iio: chemical: vz89x: abstract chip configuration Matt Ranostay
2016-08-29 16:48   ` Jonathan Cameron
2016-08-25  6:44 ` [PATCH v2 2/4] iio: chemical: vz89x: add support for VZ89TE part Matt Ranostay
2016-08-29 16:49   ` Jonathan Cameron
2016-08-25  6:44 ` [PATCH v2 3/4] iio: chemical: vz89x: prevent corrupted buffer from being read Matt Ranostay
2016-08-29 17:01   ` Jonathan Cameron [this message]
2016-08-25  6:44 ` [PATCH v2 4/4] iio: chemical: vz89x: remove mutex and replace with iio_device_*_direct_mode Matt Ranostay
2016-08-29 16:56   ` Jonathan Cameron

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=1b1d4202-e3a4-dc38-2707-cb1a1aab543c@kernel.org \
    --to=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=mranostay@gmail.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).