From: Tom Rix <t...@redhat.com>

commit f71e41e23e129640f620b65fc362a6da02580310 upstream.

Potential error return is not checked.  This can lead to use
of undefined data.

Detected by clang static analysis.

st_lsm6dsx_shub.c:540:8: warning: Assigned value is garbage or undefined
        *val = (s16)le16_to_cpu(*((__le16 *)data));
             ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fixes: c91c1c844ebd ("iio: imu: st_lsm6dsx: add i2c embedded controller 
support")
Signed-off-by: Tom Rix <t...@redhat.com
Cc: <sta...@vger.kernel.org>
Reviewed-by: Andy Shevchenko <andy.shevche...@gmail.com>
Link: https://lore.kernel.org/r/20200809175551.6794-1-t...@redhat.com
Signed-off-by: Jonathan Cameron <jonathan.came...@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gre...@linuxfoundation.org>

---
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c |    2 ++
 1 file changed, 2 insertions(+)

--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c
@@ -313,6 +313,8 @@ st_lsm6dsx_shub_read(struct st_lsm6dsx_s
 
        err = st_lsm6dsx_shub_read_output(hw, data,
                                          len & ST_LS6DSX_READ_OP_MASK);
+       if (err < 0)
+               return err;
 
        st_lsm6dsx_shub_master_enable(sensor, false);
 


Reply via email to