Squashed 'LYNQ_PUBLIC/' changes from 994e41a76..f3dd8cbdf

f3dd8cbdf [Feature][ZK-92] ftp gpslog to soc with syslog
8bb9992d3 [Feature][API-1508] in NMEA-statement for ZK ,transfer BD to GB
17579bbfa [BugFix][API-1564]fix File descriptor leakage
9c8bb35ff Merge "[Bugfix][API-1561][mtklog]  support mtk log slim fota upgrade"
926d2ad75 [Bugfix][API-1561][mtklog]  support mtk log slim fota upgrade
4bcc14334 Merge "[Bugfix][ZK-78][FOTA]get process and upgrade status error when start fota up status"
610236b60 [Bugfix][ZK-78][FOTA]get process and upgrade status error when start fota up status
f700d98cb Merge "[Bugfix][API-1473][mdlog] lynq_query_registration_state type Voice  lac cid error"
0c874421d [Feature][T8TSK-320]Print the reason for the PDN when disconnected by the modem into the syslog
dac13540e Merge "[Feature][API-1406][API-1113]Adjust SEND_SMS timeout"
31850f3e5 Merge "[Feature][API-1557] FIX libvendor-ril can`t connected RILD issue"
d3a8f5da1 [Feature][API-1557] FIX libvendor-ril can`t connected RILD issue
2f4c07922 Merge "[Feature][T8TSK-316][rtp] rtp confirm to the standard of Geely"
1ee60ec01 Merge "[Bugfix][API-1551[network]  lynq_set_vlan_info, vlan_info is "", ret 8004"
98beaeaf3 Merge "[Bugfix][API-1534]After turning on the USB port, delay for 3 seconds to make a  call"
786e97304 [Feature][T8TSK-289] missing wom when add telephonyware to LYNQ_PUBLIC repo 0
d25d37156 [Bugfix][API-1534]After turning on the USB port, delay for 3 seconds to make a  call
4157623f6 [Feature][T8TSK-316][rtp] rtp confirm to the standard of Geely
c66c73d5d [Bugfix][API-1551[network]  lynq_set_vlan_info, vlan_info is "", ret 8004
4bf2e2e0b [Feature][API-1406][API-1113]Adjust SEND_SMS timeout
4b1c33121 [Bugfix][API-1473][mdlog] lynq_query_registration_state type Voice  lac cid error

git-subtree-dir: LYNQ_PUBLIC
git-subtree-split: f3dd8cbdf17f75f5c9672368b59c1cd59194fce6

Change-Id: Ie206616813b8064220450958d9f91e5048c08ac2
diff --git a/IC_src/mtk/lib/liblynq-wifi6/libwifi6.c b/IC_src/mtk/lib/liblynq-wifi6/libwifi6.c
index 60c4224..dbc9ef1 100755
--- a/IC_src/mtk/lib/liblynq-wifi6/libwifi6.c
+++ b/IC_src/mtk/lib/liblynq-wifi6/libwifi6.c
@@ -214,7 +214,7 @@
 
 static void notify_service_invoke_fail(int error)
 {
-    struct local_wpa_ctrl *lynq_wpa_ctrl = NULL;
+    struct wpa_ctrl *lynq_wpa_ctrl = NULL;
     pthread_mutex_lock(&s_global_check_mutex);
     if (error == -2) //timeout
     {
@@ -232,15 +232,19 @@
         {
             s_service_invoke_timeout_cnt = FAKE_MAX_INT_VALUE;
             pthread_cond_signal(&s_global_check_cond);
-        }
-        wpa_ctrl_close(lynq_wpa_ctrl);
+        }else
+         {
+            wpa_ctrl_close(lynq_wpa_ctrl);
+         }
         lynq_wpa_ctrl = wpa_ctrl_open(CTRL_PATH[1]);
         if (lynq_wpa_ctrl == NULL)
         {
             s_service_invoke_timeout_cnt = FAKE_MAX_INT_VALUE;
             pthread_cond_signal(&s_global_check_cond);
+        }else
+        {
+            wpa_ctrl_close(lynq_wpa_ctrl);
         }
-        wpa_ctrl_close(lynq_wpa_ctrl);
     }
 
     pthread_mutex_unlock(&s_global_check_mutex);
@@ -1582,18 +1586,31 @@
         pthread_join(g_sta_watcher_pid, NULL);
     if (g_sta_auto_watcher_pid != 0)
         pthread_join(g_sta_auto_watcher_pid, NULL);
-    if (g_lynq_wpa_ctrl[0] != NULL)
-        wpa_ctrl_close(g_lynq_wpa_ctrl[0]);
-    if (g_lynq_wpa_ctrl[1] != NULL)
-        wpa_ctrl_close(g_lynq_wpa_ctrl[1]);
+    if ( g_lynq_wpa_ctrl[0] != NULL)
+    {
+        if(g_lynq_wpa_ctrl[0]->ctrl != NULL)
+        {
+             wpa_ctrl_close(g_lynq_wpa_ctrl[0]->ctrl);
+        }
+        free(g_lynq_wpa_ctrl[0]);
+        g_lynq_wpa_ctrl[0] = NULL;
+    }
+
+    if ( g_lynq_wpa_ctrl[1] != NULL )
+    {
+        if( g_lynq_wpa_ctrl[1]->ctrl != NULL )
+        {
+            wpa_ctrl_close(g_lynq_wpa_ctrl[1]->ctrl);
+        }
+        free(g_lynq_wpa_ctrl[1]);
+        g_lynq_wpa_ctrl[1] = NULL;
+    }
     if (g_ap_tmp_watcher_pid != 0)
         pthread_join(g_ap_tmp_watcher_pid, NULL);
     g_ap_watcher_pid = 0;
     g_sta_watcher_pid = 0;
     g_sta_auto_watcher_pid = 0;
 //    g_ap_tmp_watcher_pid = 0;
-    g_lynq_wpa_ctrl[0] = NULL;
-    g_lynq_wpa_ctrl[1] = NULL;
     g_history_disconnect_valid_num = 0;   //clean history_disconenct_list info
     system("systemctl stop wg870_drv_insmod.service");
     pthread_mutex_unlock(&s_check_wpa_ctrl_mutex);