History

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.

Luiz Augusto von Dentz committed 3 years ago

Commit 7aca0ac1 parent 241f5191 file · +16 −6Browse files

Showing the changes to net (1 of 1 file). Show all

Unified · Split

net/bluetooth/hci_event.c+16−6
@@ -801,9 +801,6 @@ static u8 hci_cc_write_auth_payload_timeout(struct hci_dev *hdev, void *data, · 800 unmodified lines
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;
@@ -811,9 +808,17 @@ static u8 hci_cc_write_auth_payload_timeout(struct hci_dev *hdev, void *data, · 1 unmodified line
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, · 2860 unmodified lines
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: