Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iio: gyro: itg3200: Fix unchecked return value in read_raw

The return value from itg3200_read_reg_s16() is stored in ret but
never checked. The function unconditionally returns IIO_VAL_INT,
ignoring potential I2C read failures. This causes garbage data to
be returned to userspace when the read fails, with no error reported.

Add proper error checking to propagate the failure to callers.

Fixes: 9dbf091da080 ("iio: gyro: Add itg3200")
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Antoniu Miclaus and committed by
Jonathan Cameron
b79b24f5 53f0a73f

+2
+2
drivers/iio/gyro/itg3200_core.c
··· 93 93 case IIO_CHAN_INFO_RAW: 94 94 reg = (u8)chan->address; 95 95 ret = itg3200_read_reg_s16(indio_dev, reg, val); 96 + if (ret) 97 + return ret; 96 98 return IIO_VAL_INT; 97 99 case IIO_CHAN_INFO_SCALE: 98 100 *val = 0;