mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stepan Ionichev <sozdayvek@gmail.com>
To: jic23@kernel.org
Cc: dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 3/4] iio: light: apds9960: use devm_pm_runtime_enable() to fix probe error path
Date: Fri, 29 May 2026 15:45:43 +0500	[thread overview]
Message-ID: <abf95e4e9a43c08ce429578ea067155ff5178d73.1780051096.git.sozdayvek@gmail.com> (raw)
In-Reply-To: <cover.1780051096.git.sozdayvek@gmail.com>

apds9960_probe() calls pm_runtime_enable() and then several operations
that may fail through goto error_power_down, ending with
iio_device_register().  None of those error paths call
pm_runtime_disable(), so the runtime PM enable_count leaks on probe
failure and on subsequent rebind.

Switch to devm_pm_runtime_enable() so the enable (and the matching
dont_use_autosuspend) are torn down automatically.  The probe error path
on devm_pm_runtime_enable() itself is a plain return because no hardware
has been powered on at that point.  The pm_runtime_disable() and
pm_runtime_set_suspended() calls in apds9960_remove() are dropped; the
devm action runs after .remove() and handles the teardown.

Signed-off-by: Stepan Ionichev <sozdayvek@gmail.com>
---
 drivers/iio/light/apds9960.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/light/apds9960.c b/drivers/iio/light/apds9960.c
index 785c5dbe2d08..edbf149b931e 100644
--- a/drivers/iio/light/apds9960.c
+++ b/drivers/iio/light/apds9960.c
@@ -1074,7 +1074,9 @@ static int apds9960_probe(struct i2c_client *client)
 	if (ret)
 		goto error_power_down;
 
-	pm_runtime_enable(&client->dev);
+	ret = devm_pm_runtime_enable(&client->dev);
+	if (ret)
+		return ret;
 	pm_runtime_set_autosuspend_delay(&client->dev, 5000);
 	pm_runtime_use_autosuspend(&client->dev);
 
@@ -1123,8 +1125,6 @@ static void apds9960_remove(struct i2c_client *client)
 	struct apds9960_data *data = iio_priv(indio_dev);
 
 	iio_device_unregister(indio_dev);
-	pm_runtime_disable(&client->dev);
-	pm_runtime_set_suspended(&client->dev);
 	apds9960_set_powermode(data, 0);
 }
 
-- 
2.43.0


  parent reply	other threads:[~2026-05-29 10:46 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-29 10:45 [PATCH 0/4] iio: PM-enable leak on probe error path (goto-variant drivers) Stepan Ionichev
2026-05-29 10:45 ` [PATCH 1/4] iio: light: pa12203001: use devm_pm_runtime_enable() to fix probe error path Stepan Ionichev
2026-05-29 17:19   ` Jonathan Cameron
2026-05-29 10:45 ` [PATCH 2/4] iio: light: us5182d: " Stepan Ionichev
2026-05-29 17:20   ` Jonathan Cameron
2026-05-29 10:45 ` Stepan Ionichev [this message]
2026-05-29 17:22   ` [PATCH 3/4] iio: light: apds9960: " Jonathan Cameron
2026-05-29 10:45 ` [PATCH 4/4] iio: accel: mma8452: " Stepan Ionichev
2026-05-29 17:23   ` Jonathan Cameron
2026-05-29 13:08 ` [PATCH 0/4] iio: PM-enable leak on probe error path (goto-variant drivers) Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=abf95e4e9a43c08ce429578ea067155ff5178d73.1780051096.git.sozdayvek@gmail.com \
    --to=sozdayvek@gmail.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®