Merge "IPACM:  delete dependency even wlan rules are not clean"
diff --git a/ipacm/src/IPACM_Lan.cpp b/ipacm/src/IPACM_Lan.cpp
old mode 100644
new mode 100755
index a3e6f9a..6daa7cc
--- a/ipacm/src/IPACM_Lan.cpp
+++ b/ipacm/src/IPACM_Lan.cpp
@@ -1322,9 +1322,6 @@
 		handle_wan_down();
 	}
 
-	/* Delete corresponding ipa_rm_resource_name of RX-endpoint after delete all IPV4V6 FT-rule */ 
-	IPACM_Iface::ipacmcfg->DelRmDepend(IPACM_Iface::ipacmcfg->ipa_client_rm_map_tbl[rx_prop->rx[0].src_pipe]);	
-
 fail:
 	if (tx_prop != NULL)
 	{
@@ -1339,5 +1336,8 @@
 		free(iface_query);
 	}
 
+	/* Delete corresponding ipa_rm_resource_name of RX-endpoint after delete all IPV4V6 FT-rule */ 
+	IPACM_Iface::ipacmcfg->DelRmDepend(IPACM_Iface::ipacmcfg->ipa_client_rm_map_tbl[rx_prop->rx[0].src_pipe]);	
+	
 	return res;
 }
diff --git a/ipacm/src/IPACM_Wlan.cpp b/ipacm/src/IPACM_Wlan.cpp
old mode 100644
new mode 100755
index 2fa4381..eda871f
--- a/ipacm/src/IPACM_Wlan.cpp
+++ b/ipacm/src/IPACM_Wlan.cpp
@@ -329,6 +329,16 @@
 	struct ipa_ioc_copy_hdr sCopyHeader;
 	struct ipa_ioc_add_hdr *pHeaderDescriptor = NULL;
         uint32_t cnt;
+	int clnt_indx;
+
+	
+	clnt_indx = get_wlan_client_index(mac_addr);
+
+	if (clnt_indx != IPACM_INVALID_INDEX)
+	{
+		IPACMERR("wlan is found/attached already with index %d \n", clnt_indx);
+		return IPACM_FAILURE;
+	}	
 
 	/* start of adding header */
 	if ((num_wifi_client >= IPA_MAX_NUM_WIFI_CLIENTS) ||
@@ -1795,8 +1805,6 @@
 	/* free the wlan clients cache */
 	IPACMDBG("Free wlan clients cache\n");
 
-	/* Delete corresponding ipa_rm_resource_name of RX-endpoint after delete all IPV4V6 FT-rule */ 
-	IPACM_Iface::ipacmcfg->DelRmDepend(IPA_RM_RESOURCE_HSIC_PROD);
 fail:
 	free(wlan_client);
 	if (tx_prop != NULL)
@@ -1812,5 +1820,8 @@
 		free(iface_query);
 	}
 
+	/* Delete corresponding ipa_rm_resource_name of RX-endpoint after delete all IPV4V6 FT-rule */ 
+	IPACM_Iface::ipacmcfg->DelRmDepend(IPA_RM_RESOURCE_HSIC_PROD);
+
 	return res;
 }