Bluetooth: MGMT: Fix not generating command complete for MGMT_OP_DISCONNECT
Subsystems (2)
Luiz Augusto von Dentz
maintainerPATCH 1/1 Bluetooth: MGMT: Fix not generating command complete for MGMT_OP_DISCONNECT
From: Luiz Augusto von Dentz <[email protected]>
MGMT_OP_DISCONNECT can be called while mgmt_device_connected has not been called yet, which will cause the connection procedure to be aborted, so mgmt_device_disconnected shall still respond with command complete to MGMT_OP_DISCONNECT and just not emit MGMT_EV_DEVICE_DISCONNECTED since MGMT_EV_DEVICE_CONNECTED was never sent.
Fixes 12d4a3b2ccb3 ("Bluetooth: Move check for MGMT_CONNECTED flag into mgmt.c")
Signed-off-by Luiz Augusto von Dentz <[email protected]>
--- net/bluetooth/mgmt.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
net/bluetooth/mgmt.c +6 -4
@@ -9738,9 +9738,6 @@ void mgmt_device_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr,struct mgmt_ev_device_disconnected ev;struct sock *sk =NULL ; -if (!mgmt_connected) -return ; -if (link_type !=ACL_LINK && link_type !=LE_LINK )return ;
@@ -9754,7 +9751,12 @@ void mgmt_device_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr,if (hdev->suspended) ev.reason =MGMT_DEV_DISCONN_LOCAL_HOST_SUSPEND ; -mgmt_event (MGMT_EV_DEVICE_DISCONNECTED , hdev, &ev,sizeof (ev), sk); +/* Only report MGMT_EV_DEVICE_DISCONNECTED if device is considered +* connected. +*/ +if (mgmt_connected) +mgmt_event (MGMT_EV_DEVICE_DISCONNECTED , hdev, &ev,sizeof (ev), + sk);if (sk)sock_put (sk);
Signature · 1 line
2.46.0