All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: arina.kharlamova@mbzuai.ac.ae
Cc: Arina Kharlamova via B4 Relay
	<devnull+arina.kharlamova.mbzuai.ac.ae@kernel.org>,
	Jonathan Cameron <jic23@cam.ac.uk>,
	Alan Cox <alan@linux.intel.com>,
	Eric Andersson <eric.andersson@unixphere.com>,
	Albert Zhang <xu.zhang@bosch-sensortec.com>,
	linux-input@vger.kernel.org
Subject: Re: [PATCH] Input: bma150 - Fix runtime PM usage count leak in open
Date: Sun, 29 Nov 2026 22:11:44 -0800	[thread overview]
Message-ID: <8f2eb3d31ef10a1854ea1f73ed48d918@gmail.com> (raw)
In-Reply-To: <20261129-s2p-c10-v1-1-a4e4c4a3cdad@mbzuai.ac.ae>

Hi Arina,

On Sun, Nov 29, 2026 at 11:26:31AM +0400, Arina Kharlamova via B4 Relay wrote:
> From: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
...
> @@ -347,8 +347,10 @@ static int bma150_open(struct input_dev *input)
>  	int error;
>  
>  	error = pm_runtime_get_sync(&bma150->client->dev);
> -	if (error < 0 && error != -ENOSYS)
> +	if (error < 0 && error != -ENOSYS) {
> +		pm_runtime_put_noidle(&bma150->client->dev);
>  		return error;
> +	}

Please switch this to pm_runtime_resume_and_get() instead, which drops
the usage count automatically on failure and returns 0 or a negative
error code. Since __pm_runtime_resume() returns 1 (not -ENOSYS) when
CONFIG_PM is disabled, pm_runtime_resume_and_get() returns 0 in that case
and the check simplifies to:

	error = pm_runtime_resume_and_get(&bma150->client->dev);
	if (error)
		return error;

>  	/*
>  	 * See if runtime PM woke up the device. If runtime PM
>  	 * is disabled we need to do it ourselves.
>  	 */
>  	if (bma150->mode != BMA150_MODE_NORMAL) {
>  		error = bma150_set_mode(bma150, BMA150_MODE_NORMAL);
> -		if (error)
> +		if (error) {
> +			pm_runtime_put_sync(&bma150->client->dev);
>  			return error;
> +		}
>  	}

Plain pm_runtime_put() is sufficient here; unlike bma150_close(), there
is no follow-up check on bma150->mode so there is no need to wait
synchronously for suspend on the error path.

Thanks.

-- 
Dmitry

      reply	other threads:[~2026-11-30  6:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-29  7:26 [PATCH] Input: bma150 - Fix runtime PM usage count leak in open Arina Kharlamova
2026-11-29  7:26 ` Arina Kharlamova via B4 Relay
2026-11-30  6:11 ` Dmitry Torokhov [this message]

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=8f2eb3d31ef10a1854ea1f73ed48d918@gmail.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=alan@linux.intel.com \
    --cc=arina.kharlamova@mbzuai.ac.ae \
    --cc=devnull+arina.kharlamova.mbzuai.ac.ae@kernel.org \
    --cc=eric.andersson@unixphere.com \
    --cc=jic23@cam.ac.uk \
    --cc=linux-input@vger.kernel.org \
    --cc=xu.zhang@bosch-sensortec.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.