From 6d9f23bf01b35074e29c6319c4009a1295cb4aa6 Mon Sep 17 00:00:00 2001 From: Vinit Deshpande Date: Tue, 28 Jul 2015 10:33:27 -0700 Subject: Fix a potential crash in debugging code We want to catch incorrect event_cbs; but the commands they may refer to may have been deleted by the time the debugging messages are printed. This change fixes that by printing before anything is deleted. Bug: 22401861 Change-Id: I71562af940275b43057eae1f93406291924ad567 --- bcmdhd/wifi_hal/wifi_hal.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bcmdhd/wifi_hal/wifi_hal.cpp b/bcmdhd/wifi_hal/wifi_hal.cpp index 0a6384f..b27bac2 100644 --- a/bcmdhd/wifi_hal/wifi_hal.cpp +++ b/bcmdhd/wifi_hal/wifi_hal.cpp @@ -295,6 +295,12 @@ void wifi_cleanup(wifi_handle handle, wifi_cleaned_up_handler handler) int bad_commands = 0; + for (int i = 0; i < info->num_event_cb; i++) { + cb_info *cbi = &(info->event_cb[i]); + WifiCommand *cmd = (WifiCommand *)cbi->cb_arg; + ALOGE("Command left in event_cb %p:%s", cmd, cmd->getType()); + } + while (info->num_cmd > bad_commands) { int num_cmd = info->num_cmd; cmd_info *cmdi = &(info->cmd[bad_commands]); @@ -316,7 +322,7 @@ void wifi_cleanup(wifi_handle handle, wifi_cleaned_up_handler handler) for (int i = 0; i < info->num_event_cb; i++) { cb_info *cbi = &(info->event_cb[i]); WifiCommand *cmd = (WifiCommand *)cbi->cb_arg; - ALOGE("Leaked command %p:%s", cmd, cmd->getType()); + ALOGE("Leaked command %p", cmd); } pthread_mutex_unlock(&info->cb_lock); -- cgit v1.1