mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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 1/4] iio: light: pa12203001: use devm_pm_runtime_enable() to fix probe error path
Date: Fri, 29 May 2026 18:19:39 +0100	[thread overview]
Message-ID: <20260529181939.53e85d3e@jic23-huawei> (raw)
In-Reply-To: <04c4962d435d4df8e8ce6655598c0964014392f1.1780051096.git.sozdayvek@gmail.com>

On Fri, 29 May 2026 15:45:41 +0500
Stepan Ionichev <sozdayvek@gmail.com> wrote:

> pa12203001_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 chip-disable cleanup
> stays in step with the rest of the manual unwind.  The pm_runtime_disable()
> and pm_runtime_set_suspended() calls in pa12203001_remove() are dropped;
> the devm action runs after .remove() and handles the teardown.
> 
> Signed-off-by: Stepan Ionichev <sozdayvek@gmail.com>
> ---
>  drivers/iio/light/pa12203001.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/light/pa12203001.c b/drivers/iio/light/pa12203001.c
> index 98a1f1624c75..b9f50c9070a3 100644
> --- a/drivers/iio/light/pa12203001.c
> +++ b/drivers/iio/light/pa12203001.c
> @@ -372,7 +372,9 @@ static int pa12203001_probe(struct i2c_client *client)
>  	if (ret < 0)
>  		goto out_err;
>  
> -	pm_runtime_enable(&client->dev);
> +	ret = devm_pm_runtime_enable(&client->dev);
> +	if (ret)
> +		goto out_err;

A goto after a devm call is a big warning flag.

A quick look suggests easy enough to solve with a devm_add_action_or_reset();
Probably needs to be a precursor patch to this one.



>  	pm_runtime_set_autosuspend_delay(&client->dev,
>  					 PA12203001_SLEEP_DELAY_MS);
>  	pm_runtime_use_autosuspend(&client->dev);
> @@ -395,9 +397,6 @@ static void pa12203001_remove(struct i2c_client *client)
>  
>  	iio_device_unregister(indio_dev);
>  
> -	pm_runtime_disable(&client->dev);
> -	pm_runtime_set_suspended(&client->dev);
> -
>  	ret = pa12203001_power_chip(indio_dev, PA12203001_CHIP_DISABLE);
>  	if (ret)
>  		dev_warn(&client->dev, "Failed to power down (%pe)\n",


  reply	other threads:[~2026-05-29 17:19 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 [this message]
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 ` [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=20260529181939.53e85d3e@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®