From: Himanshu Jha Date: Sat, 11 Aug 2018 10:26:36 +0000 (+0530) Subject: iio: chemical: bme680: Add check for val2 in the write_raw function X-Git-Tag: v5.15~7699^2~380^2~34 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=892e62fab4983656d3ca5df4e83fdf2b496c06e4;p=platform%2Fkernel%2Flinux-starfive.git 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 --- diff --git a/drivers/iio/chemical/bme680_core.c b/drivers/iio/chemical/bme680_core.c index 5ddeffb..87666ce 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: {