IPACM: fix ipacm crash issue

Fix ipacm crash issue in Ethernet bridging use case.
Acked-by: Shihuan Liu <shihuanl@qti.qualcomm.com>

Change-Id: I0ff8951b37cd30bce32ea17de9ee2fd9708b48af
diff --git a/ipacm/src/IPACM_Lan.cpp b/ipacm/src/IPACM_Lan.cpp
index 8efaf23..e5ff98a 100644
--- a/ipacm/src/IPACM_Lan.cpp
+++ b/ipacm/src/IPACM_Lan.cpp
@@ -330,6 +330,21 @@
 				}
 			}
 #endif
+
+#ifdef FEATURE_ETH_BRIDGE_LE
+			if(rx_prop != NULL)
+			{
+				free(rx_prop);
+			}
+			if(tx_prop != NULL)
+			{
+				free(tx_prop);
+			}
+			if(iface_query != NULL)
+			{
+				free(iface_query);
+			}
+#endif
 			delete this;
 		}
 		break;
@@ -3025,14 +3040,16 @@
 		IPACMDBG_H("depend Got pipe %d rm index : %d \n", rx_prop->rx[0].src_pipe, IPACM_Iface::ipacmcfg->ipa_client_rm_map_tbl[rx_prop->rx[0].src_pipe]);
 		IPACM_Iface::ipacmcfg->DelRmDepend(IPACM_Iface::ipacmcfg->ipa_client_rm_map_tbl[rx_prop->rx[0].src_pipe]);
 		IPACMDBG_H("Finished delete dependency \n ");
+#ifndef FEATURE_ETH_BRIDGE_LE
 		free(rx_prop);
+#endif
 	}
 
 	if (eth_client != NULL)
 	{
 		free(eth_client);
 	}
-
+#ifndef FEATURE_ETH_BRIDGE_LE
 	if (tx_prop != NULL)
 	{
 		free(tx_prop);
@@ -3041,7 +3058,7 @@
 	{
 		free(iface_query);
 	}
-
+#endif
 	is_active = false;
 	post_del_self_evt();
 
diff --git a/ipacm/src/IPACM_LanToLan.cpp b/ipacm/src/IPACM_LanToLan.cpp
index 799dfee..c3369e7 100644
--- a/ipacm/src/IPACM_LanToLan.cpp
+++ b/ipacm/src/IPACM_LanToLan.cpp
@@ -594,6 +594,7 @@
 	list<l2tp_vlan_mapping_info>::iterator it_mapping;
 	list<vlan_iface_info>::iterator it_vlan;
 	list<IPACM_LanToLan_Iface>::iterator it_iface;
+	IPACM_LanToLan_Iface *l2tp_iface;
 	l2tp_vlan_mapping_info new_mapping;
 	bool has_l2tp_iface = false;
 
@@ -637,6 +638,8 @@
 		if(it_iface->set_l2tp_iface(data->vlan_iface_name) == true)
 		{
 			has_l2tp_iface = true;
+			l2tp_iface = &(*it_iface);
+			break;
 		}
 	}
 
@@ -651,6 +654,7 @@
 				it_iface->handle_l2tp_enable();
 			}
 		}
+		l2tp_iface->switch_to_l2tp_iface();
 	}
 	return;
 }
@@ -1941,7 +1945,6 @@
 		{
 			IPACMDBG_H("This interface is l2tp interface.\n");
 			m_is_l2tp_iface = true;
-			switch_to_l2tp_iface();
 		}
 	}
 	return m_is_l2tp_iface;
diff --git a/ipacm/src/IPACM_Wlan.cpp b/ipacm/src/IPACM_Wlan.cpp
index ff8fcee..a36f0f9 100644
--- a/ipacm/src/IPACM_Wlan.cpp
+++ b/ipacm/src/IPACM_Wlan.cpp
@@ -202,6 +202,20 @@
 
 			IPACMDBG_H("Received IPA_LAN_DELETE_SELF event.\n");
 			IPACMDBG_H("ipa_WLAN (%s):ipa_index (%d) instance close \n", IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].iface_name, ipa_if_num);
+#ifdef FEATURE_ETH_BRIDGE_LE
+			if(rx_prop != NULL)
+			{
+				free(rx_prop);
+			}
+			if(tx_prop != NULL)
+			{
+				free(tx_prop);
+			}
+			if(iface_query != NULL)
+			{
+				free(iface_query);
+			}
+#endif
 			delete this;
 		}
 		break;
@@ -1926,7 +1940,9 @@
 		IPACMDBG_H("dev %s add producer dependency\n", dev_name);
 		IPACMDBG_H("depend Got pipe %d rm index : %d \n", rx_prop->rx[0].src_pipe, IPACM_Iface::ipacmcfg->ipa_client_rm_map_tbl[rx_prop->rx[0].src_pipe]);
 		IPACM_Iface::ipacmcfg->DelRmDepend(IPACM_Iface::ipacmcfg->ipa_client_rm_map_tbl[rx_prop->rx[0].src_pipe]);
+#ifndef FEATURE_ETH_BRIDGE_LE
 		free(rx_prop);
+#endif
 	}
 
 	for (i = 0; i < num_wifi_client; i++)
@@ -1940,6 +1956,7 @@
 	{
 		free(wlan_client);
 	}
+#ifndef FEATURE_ETH_BRIDGE_LE
 	if (tx_prop != NULL)
 	{
 		free(tx_prop);
@@ -1949,6 +1966,7 @@
 	{
 		free(iface_query);
 	}
+#endif
 
 	is_active = false;
 	post_del_self_evt();