Skip to contentSkip to conversation

iio: imu: st_lsm6dsx: unlock on error in st_lsm6dsx_shub_write_raw()

PATCH Applied Dan Carpenter 2 participants 2 messages Apr 22, 2020 – Apr 25, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: imu: st_lsm6dsx: unlock on error in st_lsm6dsx_shub_write_raw()

We need to release a lock if st_lsm6dsx_check_odr() fails, we can't return directly.

Fixes 76551a3c3df1 ("iio: imu: st_lsm6dsx: specify slave odr in slv_odr")
---
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c +5 -2
index 64ef07a30726..1cf98195f84d 100644
@@ -544,8 +544,10 @@ st_lsm6dsx_shub_write_raw(struct iio_dev *iio_dev,
 
 			ref_sensor = iio_priv(hw->iio_devs[ST_LSM6DSX_ID_ACC]);
 			odr = st_lsm6dsx_check_odr(ref_sensor, val, &odr_val);
-			if (odr < 0)
-				return odr;
+			if (odr < 0) {
+				err = odr;
+				goto release;
+			}
 
 			sensor->ext_info.slv_odr = val;
 			sensor->odr = odr;
@@ -557,6 +559,7 @@ st_lsm6dsx_shub_write_raw(struct iio_dev *iio_dev,
 		break;
 	}
 
+release:
 	iio_device_release_direct_mode(iio_dev);
 
 	return err;
Signature · 1 line
2.26.1
maintainer Applied
#1 lore raw
Quoted 5 lines · On Wed, 22 Apr 2020 12:38:11 +0300 Dan Carpenter <[email protected]>…

We need to release a lock if st_lsm6dsx_check_odr() fails, we can't return directly.

Fixes 76551a3c3df1 ("iio: imu: st_lsm6dsx: specify slave odr in slv_odr")

Good find.

Applied to the fixes-togreg branch of iio.git.

Thanks,

Jonathan

Quoted 29 lines
---
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c +5 -2
index 64ef07a30726..1cf98195f84d 100644
@@ -544,8 +544,10 @@ st_lsm6dsx_shub_write_raw(struct iio_dev *iio_dev,
 
 			ref_sensor = iio_priv(hw->iio_devs[ST_LSM6DSX_ID_ACC]);
 			odr = st_lsm6dsx_check_odr(ref_sensor, val, &odr_val);
-			if (odr < 0)
-				return odr;
+			if (odr < 0) {
+				err = odr;
+				goto release;
+			}
 
 			sensor->ext_info.slv_odr = val;
 			sensor->odr = odr;
@@ -557,6 +559,7 @@ st_lsm6dsx_shub_write_raw(struct iio_dev *iio_dev,
 		break;
 	}
 
+release:
 	iio_device_release_direct_mode(iio_dev);
 
 	return err;