Skip to contentSkip to conversation

Input: fix open count when closing inhibited device

PATCH In review Dmitry Torokhov 2 participants 2 messages May 2, 2023 – May 4, 2023

Subsystems (2)
lore
Share & tools
lore

Dmitry Torokhov

author maintainer
#0 lore raw

PATCH 1/1 Input: fix open count when closing inhibited device

Because the kernel increments device's open count in input_open_device() even if device is inhibited, the counter should always be decremented in input_close_device() to keep it balanced.

Fixes a181616487db ("Input: Add "inhibited" property")
---
 drivers/input/input.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/input.c +1 -1
index f791d14ecf23..8c5fdb0f858a 100644
@@ -705,7 +705,7 @@ void input_close_device(struct input_handle *handle)
 
 	__input_release_device(handle);
 
-	if (!dev->inhibited && !--dev->users) {
+	if (!--dev->users && !dev->inhibited) {
 		if (dev->poller)
 			input_dev_poller_stop(dev->poller);
 		if (dev->close)
Signature · 5 lines
2.40.1.495.gc816e09b53d-goog


-- 
Dmitry
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Dmitry Torokhov

Because the kernel increments device's open count in input_open_device() even if device is inhibited, the counter should always be decremented in input_close_device() to keep it balanced.

Fixes a181616487db ("Input: Add "inhibited" property")

Yep.

Cheers,
Peter

Quoted 23 lines
---
 drivers/input/input.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/input.c +1 -1
index f791d14ecf23..8c5fdb0f858a 100644
@@ -705,7 +705,7 @@ void input_close_device(struct input_handle *handle)
 
 	__input_release_device(handle);
 
-	if (!dev->inhibited && !--dev->users) {
+	if (!--dev->users && !dev->inhibited) {
 		if (dev->poller)
 			input_dev_poller_stop(dev->poller);
 		if (dev->close)
Signature · 5 lines
2.40.1.495.gc816e09b53d-goog


-- 
Dmitry