From b6aef0956eeea5df2573f06b4754b8fbc575d71e Mon Sep 17 00:00:00 2001 From: Dennis Jeon Date: Wed, 10 May 2023 17:18:35 +0900 Subject: HAL: Fixed to invalidate global func ptr in clean_up routine VendorHAL calls wifi_cleaned_up_handle late, giving LegacyHAL a chance to call a new API. In current implementation, VendorHAL would not call wifi_cleaned_up_handle in wifi_clean_up context(). It defers calling it to another context. wifi_cleaned_up_handle calls invalidate() and it makes global_handle_ as NULL. so, it needs to be fixed to call cleaned_up_handler in cleanup routine instead of event_loop thread. It will avoid incoming command from LegacyHAL after cleanup routine. Bug: 280956926 Bug: 285834754 Test: Regression test Change-Id: Ia12e37dc9bd5ce7041acdb38fbb10a29f1020857 Signed-off-by: Dennis Jeon (cherry picked from commit b6309b2c53ae97883eee2f75194b816614698f86) Merged-In: Ia12e37dc9bd5ce7041acdb38fbb10a29f1020857 --- bcmdhd/wifi_hal/wifi_hal.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/bcmdhd/wifi_hal/wifi_hal.cpp b/bcmdhd/wifi_hal/wifi_hal.cpp index f746f09..f3039ca 100644 --- a/bcmdhd/wifi_hal/wifi_hal.cpp +++ b/bcmdhd/wifi_hal/wifi_hal.cpp @@ -608,7 +608,6 @@ static int wifi_add_membership(wifi_handle handle, const char *group) static void internal_cleaned_up_handler(wifi_handle handle) { hal_info *info = getHalInfo(handle); - wifi_cleaned_up_handler cleaned_up_handler = info->cleaned_up_handler; ALOGI("internal clean up"); @@ -622,12 +621,6 @@ static void internal_cleaned_up_handler(wifi_handle handle) info->event_sock = NULL; } - if (cleaned_up_handler) { - ALOGI("cleanup_handler cb"); - (*cleaned_up_handler)(handle); - } else { - ALOGI("!! clean up handler is null!!"); - } DestroyResponseLock(); pthread_mutex_destroy(&info->cb_lock); free(info); @@ -641,7 +634,7 @@ void wifi_internal_module_cleanup() twt_deinit_handler(); } -void wifi_cleanup(wifi_handle handle, wifi_cleaned_up_handler handler) +void wifi_cleanup(wifi_handle handle, wifi_cleaned_up_handler cleaned_up_handler) { if (!handle) { ALOGE("Handle is null"); @@ -655,8 +648,6 @@ void wifi_cleanup(wifi_handle handle, wifi_cleaned_up_handler handler) wifi_interface_handle *ifaceHandles = NULL; wifi_interface_handle wlan0Handle; - info->cleaned_up_handler = handler; - wlan0Handle = wifi_get_wlan_interface((wifi_handle) info, ifaceHandles, numIfaceHandles); if (wlan0Handle != NULL) { @@ -728,6 +719,14 @@ void wifi_cleanup(wifi_handle handle, wifi_cleaned_up_handler handler) info->clean_up = true; + /* global func ptr be invalidated and will not call any command from legacy hal */ + if (cleaned_up_handler) { + ALOGI("cleaned_up_handler to invalidates func ptr"); + cleaned_up_handler(handle); + } else { + ALOGI("cleaned up handler is null"); + } + if (TEMP_FAILURE_RETRY(write(info->cleanup_socks[0], "Exit", 4)) < 1) { // As a fallback set the cleanup flag to TRUE ALOGE("could not write to the cleanup socket"); -- cgit v1.2.3