diff mbox series

[BlueZ] client/mgmt: Fix registering pairing callbacks

Message ID 20231003211442.3348427-1-luiz.dentz@gmail.com (mailing list archive)
State Accepted
Commit 9741e47aebcdcff343dd2ca7dadc3ec41b66744f
Headers show
Series [BlueZ] client/mgmt: Fix registering pairing callbacks | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch success CheckPatch PASS
tedd_an/GitLint success Gitlint PASS
tedd_an/BuildEll success Build ELL PASS
tedd_an/BluezMake success Bluez Make PASS
tedd_an/MakeCheck success Bluez Make Check PASS
tedd_an/MakeDistcheck success Make Distcheck PASS
tedd_an/CheckValgrind success Check Valgrind PASS
tedd_an/CheckSmatch success CheckSparse PASS
tedd_an/bluezmakeextell success Make External ELL PASS
tedd_an/IncrementalBuild success Incremental Build PASS
tedd_an/ScanBuild success Scan Build PASS

Commit Message

Luiz Augusto von Dentz Oct. 3, 2023, 9:14 p.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

Don't register pairing callbacks until mgmt.pair is called otherwise it
may take over the role of pairing agent when bluetoothctl agent is in
use.
---
 client/mgmt.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

Comments

bluez.test.bot@gmail.com Oct. 3, 2023, 10:34 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=789713

---Test result---

Test Summary:
CheckPatch                    PASS      0.38 seconds
GitLint                       PASS      0.26 seconds
BuildEll                      PASS      27.84 seconds
BluezMake                     PASS      783.27 seconds
MakeCheck                     PASS      12.19 seconds
MakeDistcheck                 PASS      160.83 seconds
CheckValgrind                 PASS      255.32 seconds
CheckSmatch                   PASS      348.54 seconds
bluezmakeextell               PASS      106.02 seconds
IncrementalBuild              PASS      659.30 seconds
ScanBuild                     PASS      1041.71 seconds



---
Regards,
Linux Bluetooth
patchwork-bot+bluetooth@kernel.org Oct. 3, 2023, 11:20 p.m. UTC | #2
Hello:

This patch was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Tue,  3 Oct 2023 14:14:42 -0700 you wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> 
> Don't register pairing callbacks until mgmt.pair is called otherwise it
> may take over the role of pairing agent when bluetoothctl agent is in
> use.
> ---
>  client/mgmt.c | 22 ++++++++++++++--------
>  1 file changed, 14 insertions(+), 8 deletions(-)

Here is the summary with links:
  - [BlueZ] client/mgmt: Fix registering pairing callbacks
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=9741e47aebcd

You are awesome, thank you!
diff mbox series

Patch

diff --git a/client/mgmt.c b/client/mgmt.c
index c056d018a9da..947d8fcd5556 100644
--- a/client/mgmt.c
+++ b/client/mgmt.c
@@ -3056,6 +3056,18 @@  static void pair_rsp(uint8_t status, uint16_t len, const void *param,
 	bt_shell_noninteractive_quit(EXIT_SUCCESS);
 }
 
+static void register_pair_callbacks(struct mgmt *mgmt, uint16_t index)
+{
+	mgmt_register(mgmt, MGMT_EV_PIN_CODE_REQUEST, index, request_pin,
+								mgmt, NULL);
+	mgmt_register(mgmt, MGMT_EV_USER_CONFIRM_REQUEST, index, user_confirm,
+								mgmt, NULL);
+	mgmt_register(mgmt, MGMT_EV_USER_PASSKEY_REQUEST, index,
+						request_passkey, mgmt, NULL);
+	mgmt_register(mgmt, MGMT_EV_PASSKEY_NOTIFY, index,
+						passkey_notify, mgmt, NULL);
+}
+
 static struct option pair_options[] = {
 	{ "help",	0, 0, 'h' },
 	{ "capability",	1, 0, 'c' },
@@ -3105,6 +3117,8 @@  static void cmd_pair(int argc, char **argv)
 	if (index == MGMT_INDEX_NONE)
 		index = 0;
 
+	register_pair_callbacks(mgmt, index);
+
 	memset(&cp, 0, sizeof(cp));
 	str2ba(argv[0], &cp.addr.bdaddr);
 	cp.addr.type = type;
@@ -5780,14 +5794,6 @@  static void register_mgmt_callbacks(struct mgmt *mgmt, uint16_t index)
 					local_name_changed, NULL, NULL);
 	mgmt_register(mgmt, MGMT_EV_DEVICE_FOUND, index, device_found,
 								mgmt, NULL);
-	mgmt_register(mgmt, MGMT_EV_PIN_CODE_REQUEST, index, request_pin,
-								mgmt, NULL);
-	mgmt_register(mgmt, MGMT_EV_USER_CONFIRM_REQUEST, index, user_confirm,
-								mgmt, NULL);
-	mgmt_register(mgmt, MGMT_EV_USER_PASSKEY_REQUEST, index,
-						request_passkey, mgmt, NULL);
-	mgmt_register(mgmt, MGMT_EV_PASSKEY_NOTIFY, index,
-						passkey_notify, mgmt, NULL);
 	mgmt_register(mgmt, MGMT_EV_UNCONF_INDEX_ADDED, index,
 					unconf_index_added, NULL, NULL);
 	mgmt_register(mgmt, MGMT_EV_UNCONF_INDEX_REMOVED, index,