iio: imu: adis: assign read val in debugfs hook only if op successful
authorAlexandru Ardelean <alexandru.ardelean@analog.com>
Fri, 1 Nov 2019 09:35:04 +0000 (11:35 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 3 Nov 2019 10:44:29 +0000 (10:44 +0000)
This was also caught by the `-Wmaybe-uninitialized` warning, which
(ironically as-is) it makes quite a lot of sense to do for this.

The code that actually calls this function will fail to copy on
the uninitialized value.   Hence, patch does not need to go into stable.

Fixes: 78026a6fde8f7 ("iio:imu:adis: Add debugfs register access support")
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/imu/adis.c

index dc2f9e061d983c6006ac74584d5a04b3403d5b39..85de565a4e806c02f89aa681f850d2641d52fa9c 100644 (file)
@@ -229,7 +229,8 @@ int adis_debugfs_reg_access(struct iio_dev *indio_dev,
                int ret;
 
                ret = adis_read_reg_16(adis, reg, &val16);
-               *readval = val16;
+               if (ret == 0)
+                       *readval = val16;
 
                return ret;
        } else {