diff options
author | Damon Kim <taekhun.kim@broadcom.com> | 2021-06-22 18:12:29 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-06-22 18:12:29 +0000 |
commit | 8741b7af1e86c63cbb6bb8ad6908c6492381dc73 (patch) | |
tree | dc40a6cec57f92f56b901f6b59fac23be32d17a4 | |
parent | d7696873dcb2771a2b91accb2f81f157ed6e0b75 (diff) | |
parent | de9afe5da70543a94a0549da4d8da2966082b140 (diff) | |
download | wlan-8741b7af1e86c63cbb6bb8ad6908c6492381dc73.tar.gz |
HAL: Fixed vendor HAL crash due to RSSI monitor operation am: de9afe5da7
Original change: https://googleplex-android-review.googlesource.com/c/platform/hardware/broadcom/wlan/+/15066269
Change-Id: Iddd5dfb8207daa3c4995aaab31ecbcd17ffac124
-rwxr-xr-x | bcmdhd/wifi_hal/common.cpp | 38 | ||||
-rwxr-xr-x | bcmdhd/wifi_hal/wifi_hal.cpp | 25 |
2 files changed, 41 insertions, 22 deletions
diff --git a/bcmdhd/wifi_hal/common.cpp b/bcmdhd/wifi_hal/common.cpp index 4a56bd6..887b530 100755 --- a/bcmdhd/wifi_hal/common.cpp +++ b/bcmdhd/wifi_hal/common.cpp @@ -105,14 +105,34 @@ wifi_error wifi_register_vendor_handler(wifi_handle handle, wifi_error result = WIFI_ERROR_OUT_OF_MEMORY; if (info->num_event_cb < info->alloc_event_cb) { - info->event_cb[info->num_event_cb].nl_cmd = NL80211_CMD_VENDOR; - info->event_cb[info->num_event_cb].vendor_id = id; - info->event_cb[info->num_event_cb].vendor_subcmd = subcmd; - info->event_cb[info->num_event_cb].cb_func = func; - info->event_cb[info->num_event_cb].cb_arg = arg; - ALOGV("Added event handler %p:%p for vendor 0x%0x and subcmd 0x%0x at %d", - arg, func, id, subcmd, info->num_event_cb); - info->num_event_cb++; + /* To avoid an unwanted duplication of the record, find first. + * Update it if the same record is already exist. + * KEY => [nl_cmd, vendor_id, vendor_subcmd] + */ + int i = 0; + bool is_update = false; + for (i = 0; i < info->num_event_cb; i++) { + if ((info->event_cb[i].nl_cmd == NL80211_CMD_VENDOR) && + (info->event_cb[i].vendor_id == id) && + (info->event_cb[i].vendor_subcmd == subcmd)) { + is_update = true; + break; + } + } + + if (is_update) { + info->event_cb[i].cb_func = func; + info->event_cb[i].cb_arg = arg; + } else { + info->event_cb[info->num_event_cb].nl_cmd = NL80211_CMD_VENDOR; + info->event_cb[info->num_event_cb].vendor_id = id; + info->event_cb[info->num_event_cb].vendor_subcmd = subcmd; + info->event_cb[info->num_event_cb].cb_func = func; + info->event_cb[info->num_event_cb].cb_arg = arg; + info->num_event_cb++; + } + ALOGI("%s ""event handler %p:%p for vendor 0x%0x and subcmd 0x%0x at %d", + is_update ? "Updated" : "Added", arg, func, id, subcmd, info->num_event_cb); result = WIFI_SUCCESS; } @@ -157,7 +177,7 @@ void wifi_unregister_vendor_handler(wifi_handle handle, uint32_t id, int subcmd) if (info->event_cb[i].nl_cmd == NL80211_CMD_VENDOR && info->event_cb[i].vendor_id == id && info->event_cb[i].vendor_subcmd == subcmd) { - ALOGV("Successfully removed event handler %p:%p for vendor 0x%0x, subcmd 0x%0x from %d", + ALOGI("Successfully removed event handler %p:%p for vendor 0x%0x, subcmd 0x%0x from %d", info->event_cb[i].cb_arg, info->event_cb[i].cb_func, id, subcmd, i); memmove(&info->event_cb[i], &info->event_cb[i+1], (info->num_event_cb - i - 1) * sizeof(cb_info)); diff --git a/bcmdhd/wifi_hal/wifi_hal.cpp b/bcmdhd/wifi_hal/wifi_hal.cpp index 8c5c7a4..8a39b38 100755 --- a/bcmdhd/wifi_hal/wifi_hal.cpp +++ b/bcmdhd/wifi_hal/wifi_hal.cpp @@ -1085,27 +1085,27 @@ public: int start() { WifiRequest request(familyId(), ifaceId()); int result = createRequest(request, 1); - if (result < 0) { - return result; - } - result = requestResponse(request); - if (result < 0) { - ALOGI("Failed to set RSSI Monitor, result = %d", result); + if (result != WIFI_SUCCESS) { + ALOGE("Failed to create request; result = %d", result); return result; } - ALOGI("Successfully set RSSI monitoring"); - result = registerVendorHandler(GOOGLE_OUI, GOOGLE_RSSI_MONITOR_EVENT); + registerVendorHandler(GOOGLE_OUI, GOOGLE_RSSI_MONITOR_EVENT); + ALOGI("Register GOOGLE_RSSI_MONITOR_EVENT handler"); - if (result < 0) { + result = requestResponse(request); + if (result != WIFI_SUCCESS) { unregisterVendorHandler(GOOGLE_OUI, GOOGLE_RSSI_MONITOR_EVENT); + ALOGE("Failed to set RSSI Monitor, result = %d", result); return result; } - ALOGI("Done!"); + + ALOGI("Successfully set RSSI monitoring"); return result; } virtual int cancel() { + unregisterVendorHandler(GOOGLE_OUI, GOOGLE_RSSI_MONITOR_EVENT); WifiRequest request(familyId(), ifaceId()); int result = createRequest(request, 0); @@ -1117,7 +1117,6 @@ public: ALOGE("failed to stop RSSI monitoring = %d", result); } } - unregisterVendorHandler(GOOGLE_OUI, GOOGLE_RSSI_MONITOR_EVENT); return WIFI_SUCCESS; } @@ -1768,7 +1767,7 @@ wifi_error wifi_set_country_code(wifi_interface_handle handle, const char *count static wifi_error wifi_start_rssi_monitoring(wifi_request_id id, wifi_interface_handle iface, s8 max_rssi, s8 min_rssi, wifi_rssi_event_handler eh) { - ALOGD("Start RSSI monitor %d", id); + ALOGI("Starting RSSI monitor %d", id); wifi_handle handle = getWifiHandle(iface); SetRSSIMonitorCommand *cmd = new SetRSSIMonitorCommand(id, iface, max_rssi, min_rssi, eh); NULL_CHECK_RETURN(cmd, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY); @@ -1788,7 +1787,7 @@ static wifi_error wifi_start_rssi_monitoring(wifi_request_id id, wifi_interface_ static wifi_error wifi_stop_rssi_monitoring(wifi_request_id id, wifi_interface_handle iface) { - ALOGD("Stopping RSSI monitor"); + ALOGI("Stopping RSSI monitor %d", id); if(id == -1) { wifi_rssi_event_handler handler; |