FM: initialize hci struct after linking fmHciDeathRecipient
Initialize hci struct after linking fmHciDeathRecipient.
Unlock the hci.on_mtx mutex before killing the fm process.
CRs-Fixed: 2653878
Change-Id: Ie66bf4c49e64aa1eddf64ef294cfcfe38149b2f4
diff --git a/fm_hci/fm_hci.cpp b/fm_hci/fm_hci.cpp
index 96aa9e1..8bad980 100644
--- a/fm_hci/fm_hci.cpp
+++ b/fm_hci/fm_hci.cpp
@@ -673,15 +673,6 @@
return FM_HC_STATUS_NULL_POINTER;
}
- memset(&hci, 0, sizeof(struct fm_hci_t));
-
- hci.cb = hci_hal->cb;
- hci.command_credits = 1;
- hci.is_tx_thread_running = false;
- hci.is_rx_thread_running = false;
- hci.state = FM_RADIO_DISABLED;
- hci_hal->hci = &hci;
-
fmHci = IFmHci::getService();
if(fmHci == nullptr) {
ALOGE("FM hal service is not running");
@@ -694,6 +685,15 @@
abort();
}
+ memset(&hci, 0, sizeof(struct fm_hci_t));
+
+ hci.cb = hci_hal->cb;
+ hci.command_credits = 1;
+ hci.is_tx_thread_running = false;
+ hci.is_rx_thread_running = false;
+ hci.state = FM_RADIO_DISABLED;
+ hci_hal->hci = &hci;
+
if (hci_initialize()) {
//wait for iniialization complete
Lock lk(hci.on_mtx);
@@ -706,6 +706,7 @@
hci.on_cond.wait_until(lk, now + std::chrono::seconds(HCI_TIMEOUT));
if (status == std::cv_status::timeout) {
ALOGE("hci_initialize failed, kill the fm process");
+ hci.on_mtx.unlock();
kill(getpid(), SIGKILL);
}
}