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.
Showing the changes to net (1 of 1 file). Show all
Unified · Split
| @@ -801,9 +801,6 @@ static u8 hci_cc_write_auth_payload_timeout(struct hci_dev *hdev, void *data, · 800 unmodified lines | |||
| 801 | 801 | ||
| 802 | bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); | 802 | bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); |
| 803 | 803 | ||
| 804 | if (rp->status) | ||
| 805 | return rp->status; | ||
| 806 | |||
| 807 | sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_AUTH_PAYLOAD_TO); | 804 | sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_AUTH_PAYLOAD_TO); |
| 808 | if (!sent) | 805 | if (!sent) |
| 809 | return rp->status; | 806 | return rp->status; |
| @@ -811,9 +808,17 @@ static u8 hci_cc_write_auth_payload_timeout(struct hci_dev *hdev, void *data, · 1 unmodified line | |||
| 811 | hci_dev_lock(hdev); | 808 | hci_dev_lock(hdev); |
| 812 | 809 | ||
| 813 | conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); | 810 | 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) | ||
| 815 | conn->auth_payload_timeout = get_unaligned_le16(sent + 2); | 817 | conn->auth_payload_timeout = get_unaligned_le16(sent + 2); |
| 816 | 818 | ||
| 819 | hci_encrypt_cfm(conn, 0); | ||
| 820 | |||
| 821 | unlock: | ||
| 817 | hci_dev_unlock(hdev); | 822 | hci_dev_unlock(hdev); |
| 818 | 823 | ||
| 819 | return rp->status; | 824 | return rp->status; |
| @@ -3680,8 +3685,13 @@ static void hci_encrypt_change_evt(struct hci_dev *hdev, void *data, · 2860 unmodified lines | |||
| 3680 | 3685 | ||
| 3681 | cp.handle = cpu_to_le16(conn->handle); | 3686 | cp.handle = cpu_to_le16(conn->handle); |
| 3682 | cp.timeout = cpu_to_le16(hdev->auth_payload_timeout); | 3687 | cp.timeout = cpu_to_le16(hdev->auth_payload_timeout); |
| 3683 | hci_send_cmd(conn->hdev, HCI_OP_WRITE_AUTH_PAYLOAD_TO, | 3688 | if (hci_send_cmd(conn->hdev, HCI_OP_WRITE_AUTH_PAYLOAD_TO, |
| 3684 | sizeof(cp), &cp); | 3689 | sizeof(cp), &cp)) { |
| 3690 | bt_dev_err(hdev, "write auth payload timeout failed"); | ||
| 3691 | goto notify; | ||
| 3692 | } | ||
| 3693 | |||
| 3694 | goto unlock; | ||
| 3685 | } | 3695 | } |
| 3686 | 3696 | ||
| 3687 | notify: | 3697 | notify: |