diff mbox series

iio: imu: st_lsm6dsx: check return value from st_lsm6dsx_sensor_set_enable

Message ID 3a7c5182cd676230eadb11510aee7317ce1b4e34.1577954098.git.lorenzo@kernel.org (mailing list archive)
State New, archived
Headers show
Series iio: imu: st_lsm6dsx: check return value from st_lsm6dsx_sensor_set_enable | expand

Commit Message

Lorenzo Bianconi Jan. 2, 2020, 8:36 a.m. UTC
Add missing return value check in st_lsm6dsx_read_oneshot disabling the
sensor. The issue is reported by coverity with the following error:

Unchecked return value:
If the function returns an error value, the error value may be mistaken
for a normal value.

Addresses-Coverity-ID: 1446733 ("Unchecked return value")
Fixes: b5969abfa8b8 ("iio: imu: st_lsm6dsx: add motion events")
Fixes: 290a6ce11d93 ("iio: imu: add support to lsm6dsx driver")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Jonathan Cameron Jan. 13, 2020, 9:43 p.m. UTC | #1
On Thu,  2 Jan 2020 09:36:29 +0100
Lorenzo Bianconi <lorenzo@kernel.org> wrote:

> Add missing return value check in st_lsm6dsx_read_oneshot disabling the
> sensor. The issue is reported by coverity with the following error:
> 
> Unchecked return value:
> If the function returns an error value, the error value may be mistaken
> for a normal value.
> 
> Addresses-Coverity-ID: 1446733 ("Unchecked return value")
> Fixes: b5969abfa8b8 ("iio: imu: st_lsm6dsx: add motion events")
> Fixes: 290a6ce11d93 ("iio: imu: add support to lsm6dsx driver")
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>

I'm going to interpret this as a cleanup / warning supression rather
than a fix and so take it through the togreg branch.  With those fixes
tags it may well get picked up for stable.  I'm not against that
but I'm not going to explicitly tag it for stable either.

Applied to the togreg branch of iio.git and pushed out as testing
for the autobuilders to play with it.

thanks,

Jonathan

> ---
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> index 0c64e35c7599..a16395598754 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> @@ -1534,8 +1534,11 @@ static int st_lsm6dsx_read_oneshot(struct st_lsm6dsx_sensor *sensor,
>  	if (err < 0)
>  		return err;
>  
> -	if (!hw->enable_event)
> -		st_lsm6dsx_sensor_set_enable(sensor, false);
> +	if (!hw->enable_event) {
> +		err = st_lsm6dsx_sensor_set_enable(sensor, false);
> +		if (err < 0)
> +			return err;
> +	}
>  
>  	*val = (s16)le16_to_cpu(data);
>
diff mbox series

Patch

diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
index 0c64e35c7599..a16395598754 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
@@ -1534,8 +1534,11 @@  static int st_lsm6dsx_read_oneshot(struct st_lsm6dsx_sensor *sensor,
 	if (err < 0)
 		return err;
 
-	if (!hw->enable_event)
-		st_lsm6dsx_sensor_set_enable(sensor, false);
+	if (!hw->enable_event) {
+		err = st_lsm6dsx_sensor_set_enable(sensor, false);
+		if (err < 0)
+			return err;
+	}
 
 	*val = (s16)le16_to_cpu(data);