Fix memory leak in __netconfig_netlink_scan_cb
[platform/core/connectivity/net-config.git] / src / wifi-netlink-scan.c
index 1e2356f..9076ea0 100755 (executable)
@@ -488,12 +488,15 @@ static int __netconfig_netlink_scan_cb(struct nl_msg *msg, void *user_data)
        __netconfig_get_security(nla_data(bss[NL80211_BSS_INFORMATION_ELEMENTS]),
                        nla_len(bss[NL80211_BSS_INFORMATION_ELEMENTS]), &sec_type, &enc_type);
 
-       if (sec_type == WIFI_SECURITY_TYPE_EAP)
+       if (sec_type == WIFI_SECURITY_TYPE_EAP) {
+               g_free(vsie);
                return NL_SKIP;
+       }
        for (GSList *list = bss_info_list; list != NULL; list = list->next) {
                struct bss_scan_info_t *bss_info = (struct bss_scan_info_t *)list->data;
                if ((g_strcmp0(bss_info->ssid, ssid) == 0) && (bss_info->security_type == sec_type)
                                && (bss_info->encryption_type == enc_type)) {
+                       g_free(vsie);
                        return NL_SKIP;
                }
        }
@@ -692,7 +695,7 @@ static int __netconfig_request_netlink_scan(struct nl_sock *socket,
 
        if (results.aborted) {
                DBG("scan aborted");
-               return 1;
+               goto out;
        }
 
 out:
@@ -702,7 +705,7 @@ out:
        nl_cb_put(cb);
        nl_socket_drop_membership(socket, mcid);
 
-       if (ret < 0)
+       if (ret < 0 || ret == 1)
                return ret;
 
        DBG("Scan done");