diff mbox series

[BlueZ,v1,1/2] shared/uhid: Fix registering UHID_START multiple times

Message ID 20240812200622.351942-1-luiz.dentz@gmail.com
State New
Headers show
Series [BlueZ,v1,1/2] shared/uhid: Fix registering UHID_START multiple times | expand

Commit Message

Luiz Augusto von Dentz Aug. 12, 2024, 8:06 p.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

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(-)

Comments

bluez.test.bot@gmail.com Aug. 12, 2024, 10:07 p.m. UTC | #1
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
diff mbox series

Patch

diff --git a/src/shared/uhid.c b/src/shared/uhid.c
index 1eddc6122990..b0a436d7862b 100644
--- a/src/shared/uhid.c
+++ b/src/shared/uhid.c
@@ -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;