Re: [PATCH v2 3/4] iio: chemical: vz89x: prevent corrupted buffer from being read

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 25/08/16 07:44, Matt Ranostay wrote:
> Signed-off-by: Matt Ranostay <mranostay@xxxxxxxxx>
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;
>  }
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux