Linux Input/HID development
 help / color / mirror / Atom feed
* [PATCH] Input: bma150 - Fix runtime PM usage count leak in open
@ 2026-11-29  7:26 Arina Kharlamova via B4 Relay
  2026-11-30  6:11 ` Dmitry Torokhov
  0 siblings, 1 reply; 2+ messages in thread
From: Arina Kharlamova via B4 Relay @ 2026-11-29  7:26 UTC (permalink / raw)
  To: Dmitry Torokhov, Jonathan Cameron, Alan Cox, Eric Andersson,
	Albert Zhang
  Cc: Dmitry Torokhov, 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.

Drop the reference on both error paths.

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.
---
 drivers/input/misc/bma150.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/input/misc/bma150.c b/drivers/input/misc/bma150.c
index 16aecc9b5ef4..67c0804e5b3b 100644
--- a/drivers/input/misc/bma150.c
+++ b/drivers/input/misc/bma150.c
@@ -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;
+	}
 
 	/*
 	 * See if runtime PM woke up the device. If runtime PM
@@ -356,8 +358,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_sync(&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

end of thread, other threads:[~2026-11-30  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-29  7:26 [PATCH] Input: bma150 - Fix runtime PM usage count leak in open Arina Kharlamova via B4 Relay
2026-11-30  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