Skip to content

Commit 7aca0ac

Browse files
committed
Bluetooth: Wait for HCI_OP_WRITE_AUTH_PAYLOAD_TO to complete
This make sure HCI_OP_WRITE_AUTH_PAYLOAD_TO completes before notifying the encryption change just as is done with HCI_OP_READ_ENC_KEY_SIZE. Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent 241f519 commit 7aca0ac

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

net/bluetooth/hci_event.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -801,19 +801,24 @@ static u8 hci_cc_write_auth_payload_timeout(struct hci_dev *hdev, void *data,
801801

802802
bt_dev_dbg(hdev, "status 0x%2.2x", rp->status);
803803

804-
if (rp->status)
805-
return rp->status;
806-
807804
sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_AUTH_PAYLOAD_TO);
808805
if (!sent)
809806
return rp->status;
810807

811808
hci_dev_lock(hdev);
812809

813810
conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle));
814-
if (conn)
811+
if (!conn) {
812+
rp->status = 0xff;
813+
goto unlock;
814+
}
815+
816+
if (!rp->status)
815817
conn->auth_payload_timeout = get_unaligned_le16(sent + 2);
816818

819+
hci_encrypt_cfm(conn, 0);
820+
821+
unlock:
817822
hci_dev_unlock(hdev);
818823

819824
return rp->status;
@@ -3680,8 +3685,13 @@ static void hci_encrypt_change_evt(struct hci_dev *hdev, void *data,
36803685

36813686
cp.handle = cpu_to_le16(conn->handle);
36823687
cp.timeout = cpu_to_le16(hdev->auth_payload_timeout);
3683-
hci_send_cmd(conn->hdev, HCI_OP_WRITE_AUTH_PAYLOAD_TO,
3684-
sizeof(cp), &cp);
3688+
if (hci_send_cmd(conn->hdev, HCI_OP_WRITE_AUTH_PAYLOAD_TO,
3689+
sizeof(cp), &cp)) {
3690+
bt_dev_err(hdev, "write auth payload timeout failed");
3691+
goto notify;
3692+
}
3693+
3694+
goto unlock;
36853695
}
36863696

36873697
notify:

0 commit comments

Comments
 (0)