The initialization function used by hci_open_dev (hci_init_req) sends many different HCI commands. The __hci_request function should only return when all of these commands have completed (or a timeout occurs). Several of these commands cause hci_req_complete to be called which causes __hci_request to return prematurely. This patch fixes the issue by adding a new hdev->req_last_cmd variable which is set during the initialization procedure. The hci_req_complete function will no longer mark the request as complete until the command matching hdev->req_last_cmd completes.
Showing the changes to include/net/bluetooth (1 of 3 files). Show all
Unified · Split
| @@ -129,6 +129,7 @@ struct hci_dev { · 128 unmodified lines | |||
| 129 | wait_queue_head_t req_wait_q; | 129 | wait_queue_head_t req_wait_q; |
| 130 | __u32 req_status; | 130 | __u32 req_status; |
| 131 | __u32 req_result; | 131 | __u32 req_result; |
| 132 | __u16 req_last_cmd; | ||
| 132 | 133 | ||
| 133 | struct inquiry_cache inq_cache; | 134 | struct inquiry_cache inq_cache; |
| 134 | struct hci_conn_hash conn_hash; | 135 | struct hci_conn_hash conn_hash; |
| @@ -693,6 +694,6 @@ struct hci_sec_filter { · 558 unmodified lines | |||
| 693 | #define hci_req_lock(d) mutex_lock(&d->req_lock) | 694 | #define hci_req_lock(d) mutex_lock(&d->req_lock) |
| 694 | #define hci_req_unlock(d) mutex_unlock(&d->req_lock) | 695 | #define hci_req_unlock(d) mutex_unlock(&d->req_lock) |
| 695 | 696 | ||
| 696 | void hci_req_complete(struct hci_dev *hdev, int result); | 697 | void hci_req_complete(struct hci_dev *hdev, __u16 cmd, int result); |
| 697 | 698 | ||
| 698 | #endif /* __HCI_CORE_H */ | 699 | #endif /* __HCI_CORE_H */ |