From eb9c90d1c8f48f2620804b79444674c8f35f1dda Mon Sep 17 00:00:00 2001 From: Ethan Chen Date: Fri, 22 Apr 2016 12:42:57 -0700 Subject: Null check before accessing AP objects * The AP item list is destroyed and re-created on driver load/unload. * Check before accessing them, as the driver may be unloaded, which may cause a null pointer dereference. REF: CYNGNOS-2559 Change-Id: If4f7600f6156d650211a7ac85b48f95f16c761e7 --- service/jni/com_android_server_wifi_Gbk2Utf.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/service/jni/com_android_server_wifi_Gbk2Utf.cpp b/service/jni/com_android_server_wifi_Gbk2Utf.cpp index 194b446..15bf316 100644 --- a/service/jni/com_android_server_wifi_Gbk2Utf.cpp +++ b/service/jni/com_android_server_wifi_Gbk2Utf.cpp @@ -488,6 +488,10 @@ jboolean setNetworkVariable(char *buf) ALOGD("parse SET_NETWORK command success, netId = %d, name = %s, value =%s, length=%d", netId, name, value, strlen(value)); + if (NULL == g_pItemListMutex) { + /* Driver is unloaded, g_pItemList, g_pItemListMutex are NULL */ + return JNI_TRUE; + } pthread_mutex_lock(g_pItemListMutex); pTmpItemNode = g_pItemList; if (NULL == pTmpItemNode) { -- cgit v1.2.3