From 46b6454d2f23936677a57cc37a0ccffeff41a185 Mon Sep 17 00:00:00 2001 From: Roshan Pius Date: Thu, 9 Mar 2017 13:09:49 -0800 Subject: [PATCH] wifi(implementation): Move out clearing on stop complete Currently, we invoke WifiLegacyHal.invalidate() inside the |on_stop_complete_internal_callback| std::function. |invalidate| nulls out |on_stop_complete_internal_callback| inside it which might be considered a violation since we're deleting the std::function object as we're executing it. Bug: 36095153 Test: Compiles, start/stop wifi multiple times. Test: Verified that a crash is not seen in asan build. Change-Id: If83c1cbee78a1b6eca12686fcc1ec1de67134f13 --- wifi/1.0/default/wifi_legacy_hal.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wifi/1.0/default/wifi_legacy_hal.cpp b/wifi/1.0/default/wifi_legacy_hal.cpp index 7390b65db9..f902e6453e 100644 --- a/wifi/1.0/default/wifi_legacy_hal.cpp +++ b/wifi/1.0/default/wifi_legacy_hal.cpp @@ -59,6 +59,8 @@ void onAsyncStopComplete(wifi_handle handle) { const auto lock = hidl_sync_util::acquireGlobalLock(); if (on_stop_complete_internal_callback) { on_stop_complete_internal_callback(handle); + // Invalidate this callback since we don't want this firing again. + on_stop_complete_internal_callback = nullptr; } } @@ -1261,7 +1263,6 @@ WifiLegacyHal::getGscanCachedResults() { void WifiLegacyHal::invalidate() { global_handle_ = nullptr; wlan_interface_handle_ = nullptr; - on_stop_complete_internal_callback = nullptr; on_driver_memory_dump_internal_callback = nullptr; on_firmware_memory_dump_internal_callback = nullptr; on_gscan_event_internal_callback = nullptr;