* [PATCH v2] Input: bma150 - Fix runtime PM usage count leak in open
@ 2026-11-30 22:29 Arina Kharlamova via B4 Relay
2026-12-01 6:11 ` Dmitry Torokhov
0 siblings, 1 reply; 2+ messages in thread
From: Arina Kharlamova via B4 Relay @ 2026-11-30 22:29 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input, Arina Kharlamova
From: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
pm_runtime_get_sync() keeps the usage count raised even when it fails,
and bma150_open() returns on that error without dropping it. The same
happens when bma150_set_mode() fails. The input core does not call
close() after a failed open(), so every failed open leaks one count.
Use pm_runtime_resume_and_get(), which drops the count when it fails,
and put the reference when setting the mode fails.
Fixes: c17ca3f5a2c9 ("Input: add driver for Bosch Sensortec's BMA150 accelerometer")
Signed-off-by: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
---
Found by checks derived from the spec2patch kernel API specifications,
with the help of an AI coding assistant (Claude); I reviewed the
analysis and the fix.
---
Changes in v2:
- Use pm_runtime_resume_and_get() and a plain pm_runtime_put() (Dmitry).
- Link to v1: https://patch.msgid.link/20261129-s2p-c10-v1-1-a4e4c4a3cdad@mbzuai.ac.ae
---
drivers/input/misc/bma150.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/input/misc/bma150.c b/drivers/input/misc/bma150.c
index 16aecc9b5ef4..c14ce8862697 100644
--- a/drivers/input/misc/bma150.c
+++ b/drivers/input/misc/bma150.c
@@ -346,8 +346,8 @@ static int bma150_open(struct input_dev *input)
struct bma150_data *bma150 = input_get_drvdata(input);
int error;
- error = pm_runtime_get_sync(&bma150->client->dev);
- if (error < 0 && error != -ENOSYS)
+ error = pm_runtime_resume_and_get(&bma150->client->dev);
+ if (error)
return error;
/*
@@ -356,8 +356,10 @@ static int bma150_open(struct input_dev *input)
*/
if (bma150->mode != BMA150_MODE_NORMAL) {
error = bma150_set_mode(bma150, BMA150_MODE_NORMAL);
- if (error)
+ if (error) {
+ pm_runtime_put(&bma150->client->dev);
return error;
+ }
}
return 0;
---
base-commit: 25faec9ce61c01fb45abf812a222c5b43c3cd5c5
change-id: 20261129-s2p-c10-1ffdd363d4ed
Best regards,
--
Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] Input: bma150 - Fix runtime PM usage count leak in open
2026-11-30 22:29 [PATCH v2] Input: bma150 - Fix runtime PM usage count leak in open Arina Kharlamova via B4 Relay
@ 2026-12-01 6:11 ` Dmitry Torokhov
0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2026-12-01 6:11 UTC (permalink / raw)
To: arina.kharlamova; +Cc: linux-input
On Tue, Dec 01, 2026 at 02:29:00AM +0400, Arina Kharlamova via B4 Relay wrote:
> From: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
>
> pm_runtime_get_sync() keeps the usage count raised even when it fails,
> and bma150_open() returns on that error without dropping it. The same
> happens when bma150_set_mode() fails. The input core does not call
> close() after a failed open(), so every failed open leaks one count.
>
> Use pm_runtime_resume_and_get(), which drops the count when it fails,
> and put the reference when setting the mode fails.
>
> Fixes: c17ca3f5a2c9 ("Input: add driver for Bosch Sensortec's BMA150 accelerometer")
> Signed-off-by: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
Applied, thank you.
--
Dmitry
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-01 6:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 22:29 [PATCH v2] Input: bma150 - Fix runtime PM usage count leak in open Arina Kharlamova via B4 Relay
2026-12-01 6:11 ` Dmitry Torokhov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox