Skip to contentSkip to conversation

iio: mma8452: Add missed iio_device_unregister() call in mma8452_probe()

PATCH Applied Chuhong Yuan 2 participants 2 messages May 28, 2020 – May 31, 2020 IIO

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 iio: mma8452: Add missed iio_device_unregister() call in mma8452_probe()

The function iio_device_register() was called in mma8452_probe(). But the function iio_device_unregister() was not called after a call of the function mma8452_set_freefall_mode() failed. Thus add the missed function call for one error case.

Fixes 1a965d405fc6 ("drivers:iio:accel:mma8452: added cleanup provision in case of failure.")

---
Changes in v2:
- Add fixes tag.
- Modify description.

 drivers/iio/accel/mma8452.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/iio/accel/mma8452.c +4 -1
index 00e100fc845a..813bca7cfc3e 100644
@@ -1685,10 +1685,13 @@ static int mma8452_probe(struct i2c_client *client,
 
 	ret = mma8452_set_freefall_mode(data, false);
 	if (ret < 0)
-		goto buffer_cleanup;
+		goto unregister_device;
 
 	return 0;
 
+unregister_device:
+	iio_device_unregister(indio_dev);
+
 buffer_cleanup:
 	iio_triggered_buffer_cleanup(indio_dev);
 
Signature · 1 line
2.26.2
maintainer Applied
#1 lore raw
Quoted 7 lines · On Thu, 28 May 2020 14:41:21 +0800 Chuhong Yuan <[email protected]> wrote:

The function iio_device_register() was called in mma8452_probe(). But the function iio_device_unregister() was not called after a call of the function mma8452_set_freefall_mode() failed. Thus add the missed function call for one error case.

Fixes 1a965d405fc6 ("drivers:iio:accel:mma8452: added cleanup provision in case of failure.")

Applied to the fixes-togreg branch of iio.git

Quoted 27 lines

---
Changes in v2:
- Add fixes tag.
- Modify description.

 drivers/iio/accel/mma8452.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/iio/accel/mma8452.c +4 -1
index 00e100fc845a..813bca7cfc3e 100644
@@ -1685,10 +1685,13 @@ static int mma8452_probe(struct i2c_client *client,
 
 	ret = mma8452_set_freefall_mode(data, false);
 	if (ret < 0)
-		goto buffer_cleanup;
+		goto unregister_device;
 
 	return 0;
 
+unregister_device:
+	iio_device_unregister(indio_dev);
+
 buffer_cleanup:
 	iio_triggered_buffer_cleanup(indio_dev);