Skip to contentSkip to conversation

shared/uhid: Fix registering UHID_START multiple times

PATCH Superseded Luiz Augusto von Dentz 2 participants 3 messages Aug 12, 2024 Bluetooth drivers

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/2 shared/uhid: Fix registering UHID_START multiple times

From: Luiz Augusto von Dentz <[email protected]>

UHID_START callback shall only be registered once otherwise there is a risk of processing input queue multiple times.

---
 src/shared/uhid.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
src/shared/uhid.c +9 -2
index 1eddc6122990..b0a436d7862b 100644
@@ -46,6 +46,7 @@ struct bt_uhid {
 	struct queue *input;
 	uint8_t type;
 	bool created;
+	unsigned int start_id;
 	bool started;
 	struct uhid_replay *replay;
 };
@@ -351,6 +352,14 @@ int bt_uhid_create(struct bt_uhid *uhid, const char *name, bdaddr_t *src,
 	if (uhid->created)
 		return 0;
 
+	/* Register callback for UHID_START if not registered yet */
+	if (!uhid->start_id) {
+		uhid->start_id = bt_uhid_register(uhid, UHID_START, uhid_start,
+									uhid);
+		if (!uhid->start_id)
+			return -ENOMEM;
+	}
+
 	memset(&ev, 0, sizeof(ev));
 	ev.type = UHID_CREATE2;
 	strncpy((char *) ev.u.create2.name, name,
@@ -378,8 +387,6 @@ int bt_uhid_create(struct bt_uhid *uhid, const char *name, bdaddr_t *src,
 	if (err)
 		return err;
 
-	bt_uhid_register(uhid, UHID_START, uhid_start, uhid);
-
 	uhid->created = true;
 	uhid->started = false;
 	uhid->type = type;
Signature · 1 line
2.46.0
author maintainer
#1 lore raw

PATCH 2/2 shared/uhid: Fix not cleanup input queue on destroy

From: Luiz Augusto von Dentz <[email protected]>

The input queue shall be cleanup on bt_uhid_destroy since that shall not be carried to the next session even if the input node is not destroyed.

---
 src/shared/uhid.c | 4 ++++
 1 file changed, 4 insertions(+)
src/shared/uhid.c +4 -0
index b0a436d7862b..37574f75888d 100644
@@ -504,6 +504,10 @@ int bt_uhid_destroy(struct bt_uhid *uhid, bool force)
 	if (!uhid)
 		return -EINVAL;
 
+	/* Cleanup input queue */
+	queue_destroy(uhid->input, free);
+	uhid->input = NULL;
+
 	/* Force destroy for non-keyboard devices - keyboards are not destroyed
 	 * on disconnect since they can glitch on reconnection losing
 	 * keypresses.
Signature · 1 line
2.46.0
#2 lore raw
In reply to Luiz Augusto von Dentz

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=878946

---Test result---

Test Summary:

CheckPatch                    PASS      2.65 seconds
GitLint                       PASS      1.13 seconds
BuildEll                      PASS      24.55 seconds
BluezMake                     PASS      1694.59 seconds
MakeCheck                     FAIL      13.66 seconds
MakeDistcheck                 FAIL      159.20 seconds
CheckValgrind                 FAIL      251.06 seconds
CheckSmatch                   PASS      353.29 seconds
bluezmakeextell               PASS      119.54 seconds
IncrementalBuild              PASS      3024.07 seconds
ScanBuild                     PASS      998.52 seconds

Details
##############################
Test: MakeCheck - FAIL
Desc: Run Bluez Make Check
Output:

make[3]: *** [Makefile:11764: test-suite.log] Error 1 make[2]: *** [Makefile:11872: check-TESTS] Error 2 make[1]: *** [Makefile:12301: check-am] Error 2
make: *** [Makefile:12303: check] Error 2
##############################
Test: MakeDistcheck - FAIL
Desc: Run Bluez Make Distcheck
Output:

Package cups was not found in the pkg-config search path. Perhaps you should add the directory containing `cups.pc' to the PKG_CONFIG_PATH environment variable
No package 'cups' found
make[4]: *** [Makefile:11764: test-suite.log] Error 1 make[3]: *** [Makefile:11872: check-TESTS] Error 2 make[2]: *** [Makefile:12301: check-am] Error 2 make[1]: *** [Makefile:12303: check] Error 2
make: *** [Makefile:12224: distcheck] Error 1
##############################
Test: CheckValgrind - FAIL
Desc: Run Bluez Make Check with Valgrind
Output:

tools/mgmt-tester.c: In function ‘main’:
tools/mgmt-tester.c:12725:5: note: variable tracking size limit exceeded with ‘-fvar-tracking-assignments’, retrying without 12725 | int main(int argc, char *argv[])

      |     ^~~~

make[3]: *** [Makefile:11764: test-suite.log] Error 1 make[2]: *** [Makefile:11872: check-TESTS] Error 2 make[1]: *** [Makefile:12301: check-am] Error 2
make: *** [Makefile:12303: check] Error 2

---
Regards,
Linux Bluetooth