Merge tag 'LA.UM.9.12.r1-15200-SMxx50.QSSI13.0' into int/13/fp4

"LA.UM.9.12.r1-15200-SMxx50.QSSI13.0"

* tag 'LA.UM.9.12.r1-15200-SMxx50.QSSI13.0':
  ipacm: Klock work issue
  ipacm: Change to avoid out of bound access for array
  ipacm: klock work issue
  ipacm: klock work issue

Change-Id: I26b9f30a2377e81ee9217f2e06649f942432e7ff
diff --git a/ipacm/src/IPACM_LanToLan.cpp b/ipacm/src/IPACM_LanToLan.cpp
index 0075418..114c461 100644
--- a/ipacm/src/IPACM_LanToLan.cpp
+++ b/ipacm/src/IPACM_LanToLan.cpp
@@ -1772,10 +1772,10 @@
 	{
 		for(i = 0; i < IPA_HDR_L2_MAX; i++)
 		{
-			IPACMDBG_H("Ref_cnt of peer l2 type %s is %d.\n", ipa_l2_hdr_type[i], ref_cnt_peer_l2_hdr_type[i]);
+			IPACMDBG_H("Ref_cnt of peer l2 type with index %d is %d.\n", i, ref_cnt_peer_l2_hdr_type[i]);
 			if(ref_cnt_peer_l2_hdr_type[i] > 0)
 			{
-				IPACMDBG_H("Hdr proc ctx for peer l2 type %s: %d\n", ipa_l2_hdr_type[i], hdr_proc_ctx_for_inter_interface[i]);
+				IPACMDBG_H("Hdr proc ctx for peer l2 type %d: %d\n", i, hdr_proc_ctx_for_inter_interface[i]);
 			}
 		}
 	}
@@ -1805,8 +1805,8 @@
 			{
 				if(ref_cnt_peer_l2_hdr_type[j] > 0)
 				{
-					IPACMDBG_H("Printing routing rule info for inter-interface communication for peer l2 type %s.\n",
-						ipa_l2_hdr_type[j]);
+					IPACMDBG_H("Printing routing rule info for inter-interface communication for peer l2 type %d.\n",
+						j);
 					IPACMDBG_H("Number of IPv4 routing rules is %d, handles:\n", it_client->inter_iface_rt_rule_hdl[j].num_hdl[IPA_IP_v4]);
 					for(k = 0; k < it_client->inter_iface_rt_rule_hdl[j].num_hdl[IPA_IP_v4]; k++)
 					{
diff --git a/ipacm/src/IPACM_Main.cpp b/ipacm/src/IPACM_Main.cpp
index 6bd117e..011bdb4 100644
--- a/ipacm/src/IPACM_Main.cpp
+++ b/ipacm/src/IPACM_Main.cpp
@@ -332,7 +332,7 @@
 			if(data_fid == NULL)
 			{
 				IPACMERR("unable to allocate memory for event_wlan data_fid\n");
-				return NULL;
+				continue;
 			}
 			ipa_get_if_index(event_wlan->name, &(data_fid->if_index));
 			evt_data.event = IPA_WLAN_AP_LINK_UP_EVENT;
@@ -349,7 +349,7 @@
 			if(data_fid == NULL)
 			{
 				IPACMERR("unable to allocate memory for event_wlan data_fid\n");
-				return NULL;
+				continue;
 			}
 			ipa_get_if_index(event_wlan->name, &(data_fid->if_index));
 			evt_data.event = IPA_WLAN_LINK_DOWN_EVENT;
@@ -365,7 +365,7 @@
 			if(data == NULL)
 			{
 				IPACMERR("unable to allocate memory for event_wlan data_fid\n");
-				return NULL;
+				continue;
 			}
 			memcpy(data->mac_addr,
 				 event_wlan->mac_addr,
@@ -385,7 +385,7 @@
 			if(data_fid == NULL)
 			{
 				IPACMERR("unable to allocate memory for event_wlan data_fid\n");
-				return NULL;
+				continue;
 			}
 			ipa_get_if_index(event_wlan->name, &(data_fid->if_index));
 			evt_data.event = IPA_WLAN_LINK_DOWN_EVENT;
@@ -401,8 +401,8 @@
 		        data = (ipacm_event_data_mac *)malloc(sizeof(ipacm_event_data_mac));
 		        if (data == NULL)
 		        {
-		    	        IPACMERR("unable to allocate memory for event_wlan data\n");
-		    	        return NULL;
+				IPACMERR("unable to allocate memory for event_wlan data\n");
+				continue;
 		        }
 			memcpy(data->mac_addr,
 						 event_wlan->mac_addr,
@@ -424,7 +424,7 @@
 			if(data_wigig == NULL)
 			{
 				IPACMERR("unable to allocate memory for event_wigig data\n");
-				return NULL;
+				continue;
 			}
 			memcpy(data_wigig->mac_addr,
 				event_wigig->client_mac_addr,
@@ -442,7 +442,7 @@
 			if(event_ex_o.num_of_attribs > IPA_DRIVER_WLAN_EVENT_MAX_OF_ATTRIBS)
 			{
 				IPACMERR("buffer size overflow\n");
-				return NULL;
+				continue;
 			}
 			length = sizeof(ipa_wlan_msg_ex)+ event_ex_o.num_of_attribs * sizeof(ipa_wlan_hdr_attrib_val);
 			IPACMDBG_H("num_of_attribs %d, length %d\n", event_ex_o.num_of_attribs, length);
@@ -450,15 +450,16 @@
 			if(event_ex == NULL )
 			{
 				IPACMERR("Unable to allocate memory\n");
-				return NULL;
+				continue;
 			}
 			memcpy(event_ex, buffer + sizeof(struct ipa_msg_meta), length);
 			data_ex = (ipacm_event_data_wlan_ex *)malloc(sizeof(ipacm_event_data_wlan_ex) + event_ex_o.num_of_attribs * sizeof(ipa_wlan_hdr_attrib_val));
-		    if (data_ex == NULL)
-		    {
+			if (data_ex == NULL)
+			{
 				IPACMERR("unable to allocate memory for event data\n");
-		    	return NULL;
-		    }
+				free(event_ex);
+				continue;
+			}
 			data_ex->num_of_attribs = event_ex->num_of_attribs;
 
 			memcpy(data_ex->attribs,
@@ -474,7 +475,9 @@
 			if(new_neigh_data == NULL)
 			{
 				IPACMERR("Failed to allocate memory.\n");
-				return NULL;
+				free(data_ex);
+				free(event_ex);
+				continue;
 			}
 			memset(new_neigh_data, 0, sizeof(ipacm_event_data_all));
 			new_neigh_data->iptype = IPA_IP_v6;
@@ -511,8 +514,8 @@
 		        data = (ipacm_event_data_mac *)malloc(sizeof(ipacm_event_data_mac));
 		        if (data == NULL)
 		        {
-		    	        IPACMERR("unable to allocate memory for event_wlan data\n");
-		    	        return NULL;
+				IPACMERR("unable to allocate memory for event_wlan data\n");
+				continue;
 		        }
 			memcpy(data->mac_addr,
 						 event_wlan->mac_addr,
@@ -531,8 +534,8 @@
 		        data = (ipacm_event_data_mac *)malloc(sizeof(ipacm_event_data_mac));
 		        if (data == NULL)
 		        {
-		    	        IPACMERR("unable to allocate memory for event_wlan data\n");
-		    	        return NULL;
+				IPACMERR("unable to allocate memory for event_wlan data\n");
+				continue;
 		        }
 			memcpy(data->mac_addr,
 						 event_wlan->mac_addr,
@@ -551,8 +554,8 @@
 		        data = (ipacm_event_data_mac *)malloc(sizeof(ipacm_event_data_mac));
 		        if (data == NULL)
 		        {
-		    	       IPACMERR("unable to allocate memory for event_wlan data\n");
-		    	       return NULL;
+				IPACMERR("unable to allocate memory for event_wlan data\n");
+				continue;
 		        }
 			memcpy(data->mac_addr,
 						 event_wlan->mac_addr,
@@ -569,7 +572,7 @@
 			if(data_fid == NULL)
 			{
 				IPACMERR("unable to allocate memory for event_ecm data_fid\n");
-				return NULL;
+				continue;
 			}
 			data_fid->if_index = event_ecm.ifindex;
 			evt_data.event = IPA_USB_LINK_UP_EVENT;
@@ -583,7 +586,7 @@
 			if(data_fid == NULL)
 			{
 				IPACMERR("unable to allocate memory for event_ecm data_fid\n");
-				return NULL;
+				continue;
 			}
 			data_fid->if_index = event_ecm.ifindex;
 			evt_data.event = IPA_LINK_DOWN_EVENT;
@@ -597,7 +600,7 @@
 			if(data_iptype == NULL)
 			{
 				IPACMERR("unable to allocate memory for event_ecm data_iptype\n");
-				return NULL;
+				continue;
 			}
 			ipa_get_if_index(event_wan.upstream_ifname, &(data_iptype->if_index));
 			ipa_get_if_index(event_wan.tethered_ifname, &(data_iptype->if_index_tether));
@@ -624,7 +627,7 @@
 			if(data_iptype == NULL)
 			{
 				IPACMERR("unable to allocate memory for event_ecm data_iptype\n");
-				return NULL;
+				continue;
 			}
 			ipa_get_if_index(event_wan.upstream_ifname, &(data_iptype->if_index));
 			ipa_get_if_index(event_wan.tethered_ifname, &(data_iptype->if_index_tether));
@@ -643,7 +646,7 @@
 			if(data_fid == NULL)
 			{
 				IPACMERR("unable to allocate memory for event data_fid\n");
-				return NULL;
+				continue;
 			}
 			ipa_get_if_index(event_wan.upstream_ifname, &(data_fid->if_index));
 			evt_data.event = IPA_WAN_EMBMS_LINK_UP_EVENT;
@@ -688,7 +691,7 @@
 			if(data_fid == NULL)
 			{
 				IPACMERR("unable to allocate memory for xlat event\n");
-				return NULL;
+				continue;
 			}
 			ipa_get_if_index(event_wan.upstream_ifname, &(data_fid->if_index));
 			evt_data.event = IPA_LINK_UP_EVENT;
@@ -702,7 +705,7 @@
 			if(data_fid == NULL)
 			{
 				IPACMERR("unable to allocate memory for xlat event\n");
-				return NULL;
+				continue;
 			}
 			ipa_get_if_index(event_wan.upstream_ifname, &(data_fid->if_index));
 			evt_data.event = IPA_WAN_XLAT_CONNECT_EVENT;
@@ -716,7 +719,7 @@
 			if(data_tethering_stats == NULL)
 			{
 				IPACMERR("unable to allocate memory for event data_tethering_stats\n");
-				return NULL;
+				continue;
 			}
 			memcpy(data_tethering_stats,
 					 &event_data_stats,
@@ -733,7 +736,7 @@
 			if(data_network_stats == NULL)
 			{
 				IPACMERR("unable to allocate memory for event data_network_stats\n");
-				return NULL;
+				continue;
 			}
 			memcpy(data_network_stats,
 					 &event_network_stats,
@@ -801,7 +804,7 @@
 			if(vlan_info == NULL)
 			{
 				IPACMERR("Failed to allocate memory.\n");
-				return NULL;
+				continue;
 			}
 			memcpy(vlan_info, buffer + sizeof(struct ipa_msg_meta), sizeof(*vlan_info));
 			evt_data.event = IPA_ADD_VLAN_IFACE;
@@ -813,7 +816,7 @@
 			if(vlan_info == NULL)
 			{
 				IPACMERR("Failed to allocate memory.\n");
-				return NULL;
+				continue;
 			}
 			memcpy(vlan_info, buffer + sizeof(struct ipa_msg_meta), sizeof(*vlan_info));
 			evt_data.event = IPA_DEL_VLAN_IFACE;
@@ -825,7 +828,7 @@
 			if(mapping == NULL)
 			{
 				IPACMERR("Failed to allocate memory.\n");
-				return NULL;
+				continue;
 			}
 			memcpy(mapping, buffer + sizeof(struct ipa_msg_meta), sizeof(*mapping));
 			evt_data.event = IPA_ADD_L2TP_VLAN_MAPPING;
@@ -837,7 +840,7 @@
 			if(mapping == NULL)
 			{
 				IPACMERR("Failed to allocate memory.\n");
-				return NULL;
+				continue;
 			}
 			memcpy(mapping, buffer + sizeof(struct ipa_msg_meta), sizeof(*mapping));
 			evt_data.event = IPA_DEL_L2TP_VLAN_MAPPING;
@@ -853,7 +856,7 @@
 			{
 				IPACMERR("qmap_id (%d) beyond the Max range (%d), abort\n",
 				coalesce_info.qmap_id, IPA_MAX_NUM_SW_PDNS);
-				return NULL;
+				continue;
 			}
 			IPACM_Wan::coalesce_config(coalesce_info.qmap_id, coalesce_info.tcp_enable, coalesce_info.udp_enable);
 			/* Notify all LTE instance to do RSC configuration */
@@ -869,7 +872,7 @@
 			{
 				IPACMERR("qmap_id (%d) beyond the Max range (%d), abort\n",
 				coalesce_info.qmap_id, IPA_MAX_NUM_SW_PDNS);
-				return NULL;
+				continue;
 			}
 			IPACM_Wan::coalesce_config(coalesce_info.qmap_id, false, false);
 			/* Notify all LTE instance to do RSC configuration */
@@ -884,7 +887,7 @@
 			if(mtu_event == NULL)
 			{
 				IPACMERR("Failed to allocate memory.\n");
-				return NULL;
+				continue;
 			}
 			mtu_info = &(mtu_event->mtu_info);
 			memcpy(mtu_info, buffer + sizeof(struct ipa_msg_meta), sizeof(struct ipa_mtu_info));
@@ -894,7 +897,7 @@
 			{
 				IPACMERR("ip_type (%d) beyond the Max range (%d), abort\n",
 				mtu_info->ip_type, IPA_IP_MAX);
-				return NULL;
+				continue;
 			}
 
 			ipa_get_if_index(mtu_info->if_name, &(mtu_event->if_index));