[PATCH] iio: proximity: srf04: fix error handling in srf04_probe()

Salah Triki <[email protected]>
Newsgroups org.kernel.vger.linux-iio,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
If pm_runtime_set_active() fails during srf04_probe(),
iio_device_unregister() is called to cleanup, but the driver continues to
execute pm_runtime_enable() and pm_runtime_idle() instead of aborting
probe.

Fix this by returning 'ret' immediately inside the error path if
pm_runtime_set_active() fails, preventing invalid runtime PM operations on
an unregistered device.

Fixes: 2251157b335b ("iio: srf04: add power management feature")
Signed-off-by: Salah Triki <[email protected]>
---
 drivers/iio/proximity/srf04.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/proximity/srf04.c b/drivers/iio/proximity/srf04.c
index 7be50bdebfcb..e03f3f0dee04 100644
--- a/drivers/iio/proximity/srf04.c
+++ b/drivers/iio/proximity/srf04.c
@@ -330,6 +330,7 @@ static int srf04_probe(struct platform_device *pdev)
 		if (ret) {
 			dev_err(data->dev, "pm_runtime_set_active: %d\n", ret);
 			iio_device_unregister(indio_dev);
+			return ret;
 		}
 
 		pm_runtime_enable(data->dev);
-- 
2.43.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.