From 892e62fab4983656d3ca5df4e83fdf2b496c06e4 Mon Sep 17 00:00:00 2001 From: Himanshu Jha Date: Sat, 11 Aug 2018 15:56:36 +0530 Subject: [PATCH] iio: chemical: bme680: Add check for val2 in the write_raw function val2 is responsible for the floating part of the number to be written to the device. We don't need the floating part while writing the oversampling ratio for BME680 since the available oversampling ratios are pure natural numbers. So, add a sanity check to make sure val2 is 0. Signed-off-by: Himanshu Jha Signed-off-by: Jonathan Cameron --- drivers/iio/chemical/bme680_core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/iio/chemical/bme680_core.c b/drivers/iio/chemical/bme680_core.c index 5ddeffb29fb0..87666ce8915f 100644 --- a/drivers/iio/chemical/bme680_core.c +++ b/drivers/iio/chemical/bme680_core.c @@ -800,6 +800,9 @@ static int bme680_write_raw(struct iio_dev *indio_dev, { struct bme680_data *data = iio_priv(indio_dev); + if (val2 != 0) + return -EINVAL; + switch (mask) { case IIO_CHAN_INFO_OVERSAMPLING_RATIO: {