From: Jonathan Cameron <jic23@kernel.org>
To: Stepan Ionichev <sozdayvek@gmail.com>
Cc: dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/4] iio: light: us5182d: use devm_pm_runtime_enable() to fix probe error path
Date: Fri, 29 May 2026 18:20:34 +0100 [thread overview]
Message-ID: <20260529182034.12dfa221@jic23-huawei> (raw)
In-Reply-To: <ba9abb34df8a0b16015817c44bd4a22d53d2c065.1780051096.git.sozdayvek@gmail.com>
On Fri, 29 May 2026 15:45:42 +0500
Stepan Ionichev <sozdayvek@gmail.com> wrote:
> us5182d_probe() calls pm_runtime_enable() and then iio_device_register().
> If iio_device_register() fails the function jumps to out_err but the
> existing out_err handler does not call pm_runtime_disable(), leaking the
> runtime PM enable_count 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. On its new error path
> the probe jumps to the existing out_err label so the shutdown_en() cleanup
> stays in step with the rest of the manual unwind. The pm_runtime_disable()
> and pm_runtime_set_suspended() calls in us5182d_remove() are dropped; the
> devm action runs after .remove() and handles the teardown.
>
> Signed-off-by: Stepan Ionichev <sozdayvek@gmail.com>
Same a for patch 1. Needs more work so there is no goto.
> ---
> drivers/iio/light/us5182d.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/iio/light/us5182d.c b/drivers/iio/light/us5182d.c
> index d2f5a44892a8..ada75f710bfc 100644
> --- a/drivers/iio/light/us5182d.c
> +++ b/drivers/iio/light/us5182d.c
> @@ -880,7 +880,9 @@ static int us5182d_probe(struct i2c_client *client)
> goto out_err;
> }
>
> - pm_runtime_enable(&client->dev);
> + ret = devm_pm_runtime_enable(&client->dev);
> + if (ret)
> + goto out_err;
> pm_runtime_set_autosuspend_delay(&client->dev,
> US5182D_SLEEP_MS);
> pm_runtime_use_autosuspend(&client->dev);
> @@ -904,9 +906,6 @@ static void us5182d_remove(struct i2c_client *client)
>
> iio_device_unregister(i2c_get_clientdata(client));
>
> - pm_runtime_disable(&client->dev);
> - pm_runtime_set_suspended(&client->dev);
> -
> ret = us5182d_shutdown_en(data, US5182D_CFG0_SHUTDOWN_EN);
> if (ret)
> dev_warn(&client->dev, "Failed to shut down (%pe)\n",
next prev parent reply other threads:[~2026-05-29 17:20 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 [this message]
2026-05-29 10:45 ` [PATCH 3/4] iio: light: apds9960: " Stepan Ionichev
2026-05-29 17:22 ` 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=20260529182034.12dfa221@jic23-huawei \
--to=jic23@kernel.org \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=sozdayvek@gmail.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®