Skip to contentSkip to conversation

input/hog: Remove HID device after HoG device disconnects

PATCH In review Bastien Nocera 2 participants 2 messages Jun 14, 2019 – Jul 15, 2019 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 input/hog: Remove HID device after HoG device disconnects

From: Benjamin Tissoires <[email protected]>

When the Bluetooth LE device disconnects, make sure to also destroy the uHID device so that we don't have a lingering HID device accessible from user-space.

This also fixes the input subsystem never seeing the device reattaching, causing settings that should be applied on connection not to be applied.

https://bugzilla.kernel.org/show_bug.cgi?id=202909

---
 profiles/input/hog.c | 2 ++
 1 file changed, 2 insertions(+)
profiles/input/hog.c +2 -0
index 23c9c1529..83c017dcb 100644
@@ -199,6 +199,8 @@ static int hog_disconnect(struct btd_service *service)
 	struct hog_device *dev = btd_service_get_user_data(service);
 
 	bt_hog_detach(dev->hog);
+	bt_hog_unref(dev->hog);
+	dev->hog = NULL;
 
 	btd_service_disconnecting_complete(service, 0);
 
Signature · 1 line
2.21.0
#1 lore raw

Hi,

Quoted 21 lines · On Friday, 14 June 2019 17:31:25 CEST Bastien Nocera wrote:

From: Benjamin Tissoires <[email protected]>

When the Bluetooth LE device disconnects, make sure to also destroy the uHID device so that we don't have a lingering HID device accessible from user-space.

This also fixes the input subsystem never seeing the device reattaching, causing settings that should be applied on connection not to be applied.

https://bugzilla.kernel.org/show_bug.cgi?id=202909

---
 profiles/input/hog.c | 2 ++
 1 file changed, 2 insertions(+)
profiles/input/hog.c +0 -0
index 23c9c1529..83c017dcb 100644

profiles/input/hog.c static int hog_disconnect(struct btd_service *service) · line 205

Quoted 7 lines
profiles/input/hog.c +2 -0
@@ -199,6 +199,8 @@ static int hog_disconnect(struct btd_service *service)
 	struct hog_device *dev = btd_service_get_user_data(service);
 
 	bt_hog_detach(dev->hog);
+	bt_hog_unref(dev->hog);
+	dev->hog = NULL;
 
 	btd_service_disconnecting_complete(service, 0);

I've tested this with device I have and introduced delay is acceptable imho. Since this fix end-user usabiblity for some of the devices on the market I think the trade-off is justified.

Patch is now applied.

Signature · 2 lines
pozdrawiam
Szymon Janc