Skip to contentSkip to conversation

iio: proximity: srf04: fix error handling in srf04_probe()

PATCH In review Salah Triki 2 participants 2 messages Aug 19 – Aug 20

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

PATCH 1/1 iio: proximity: srf04: fix error handling in srf04_probe()

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")
---
 drivers/iio/proximity/srf04.c | 1 +
 1 file changed, 1 insertion(+)
drivers/iio/proximity/srf04.c +1 -0
index 7be50bdebfcb..e03f3f0dee04 100644
@@ -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);
Signature · 1 line
2.43.0
maintainer
#1 lore raw
Quoted 11 lines · On Wed, 19 Aug 2026 20:03:17 +0100 Salah Triki <[email protected]> wrote:

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")

Fixed a few weeks back.

Thanks

Jonathan

Quoted 16 lines
---
 drivers/iio/proximity/srf04.c | 1 +
 1 file changed, 1 insertion(+)
drivers/iio/proximity/srf04.c +1 -0
index 7be50bdebfcb..e03f3f0dee04 100644
@@ -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);