QcomModulePkg: Eliminate Asserts in ABL code

Execution should not assert in ABL application instead
print the error message and return to caller.

Change-Id: Ie171b77a5e8d76dd89412287e3490d1574400ecc
diff --git a/QcomModulePkg/Application/FastbootApp/FastbootCmds.c b/QcomModulePkg/Application/FastbootApp/FastbootCmds.c
index cda2734..d563d8d 100644
--- a/QcomModulePkg/Application/FastbootApp/FastbootCmds.c
+++ b/QcomModulePkg/Application/FastbootApp/FastbootCmds.c
@@ -1366,8 +1366,10 @@
 		AcceptCmd (Size, (CHAR8 *) Data);
 	else if (mState == ExpectDataState)
 		AcceptData (Size, Data);
-	else
-		ASSERT (FALSE);
+	else {
+		DEBUG((EFI_D_ERROR, "DataReady Unknown status received\r\n"));
+		return;
+	}
 }
 
 STATIC VOID FatalErrorNotify(
diff --git a/QcomModulePkg/Library/BootLib/BootStats.c b/QcomModulePkg/Library/BootLib/BootStats.c
index f12ad28..3f7960b 100644
--- a/QcomModulePkg/Library/BootLib/BootStats.c
+++ b/QcomModulePkg/Library/BootLib/BootStats.c
@@ -84,7 +84,7 @@
 		if (BootStatId >= BS_MAX)
 		{
 			DEBUG((EFI_D_ERROR, "Bad BootStat id: %u, Max: %u\n", BootStatId, BS_MAX));
-			ASSERT(FALSE);
+			return;
 		}
 
 		if (BootStatId == BS_KERNEL_LOAD_START)
diff --git a/QcomModulePkg/Library/BootLib/LocateDeviceTree.c b/QcomModulePkg/Library/BootLib/LocateDeviceTree.c
index bba3ca4..6da155d 100644
--- a/QcomModulePkg/Library/BootLib/LocateDeviceTree.c
+++ b/QcomModulePkg/Library/BootLib/LocateDeviceTree.c
@@ -43,12 +43,18 @@
 	dt_node_member = (struct dt_entry_node *)
 		AllocatePool(sizeof(struct dt_entry_node));
 
-	ASSERT(dt_node_member);
+	if (!dt_node_member) {
+		DEBUG((EFI_D_ERROR, "Failed to allocate memory for dt_node_member\n"));
+		return NULL;
+	}
 
 	list_clear_node(&dt_node_member->node);
 	dt_node_member->dt_entry_m = (struct dt_entry *)
 		AllocatePool(sizeof(struct dt_entry));
-	ASSERT(dt_node_member->dt_entry_m);
+	if (!dt_node_member->dt_entry_m) {
+		DEBUG((EFI_D_ERROR, "Failed to allocate memory for dt_node_member->dt_entry_m\n"));
+		return NULL;
+	}
 
 	memset(dt_node_member->dt_entry_m ,0 ,sizeof(struct dt_entry));
 	return dt_node_member;
@@ -68,7 +74,7 @@
 	}
 }
 
-static int DeviceTreeCompatible(VOID *dtb, UINT32 dtb_size, struct dt_entry_node *dtb_list)
+static BOOLEAN DeviceTreeCompatible(VOID *dtb, UINT32 dtb_size, struct dt_entry_node *dtb_list)
 {
 	int root_offset;
 	const VOID *prop = NULL;
@@ -100,7 +106,10 @@
 	prop = fdt_getprop(dtb, root_offset, "model", &len);
 	if (prop && len > 0) {
 		model = (char *) AllocatePool(sizeof(char) * len);
-		ASSERT(model);
+		if (!model) {
+			DEBUG((EFI_D_ERROR, "Failed to allocate memory for model\n"));
+			return FALSE;
+		}
 		AsciiStrnCpyS(model, (sizeof(CHAR8)* len), prop, len);
 	} else {
 		DEBUG ((EFI_D_ERROR, "model does not exist in device tree\n"));
@@ -151,12 +160,22 @@
 		 *  If we are using dtb v2.0, then we have split board & msmdata in the DTB
 		 */
 		board_data = (struct board_id *) AllocatePool(sizeof(struct board_id) * (len_board_id / BOARD_ID_SIZE));
-		ASSERT(board_data);
+		if (!board_data) {
+			DEBUG((EFI_D_ERROR, "Failed to allocate memory for board_data\n"));
+			return FALSE;
+		}
+
 		platform_data = (struct plat_id *) AllocatePool(sizeof(struct plat_id) * (len_plat_id / PLAT_ID_SIZE));
-		ASSERT(platform_data);
+		if (!platform_data) {
+			DEBUG((EFI_D_ERROR, "Failed to allocate memory for platform_data\n"));
+			return FALSE;
+		}
 		if (dtb_ver == DEV_TREE_VERSION_V3) {
 			pmic_data = (struct pmic_id *) AllocatePool(sizeof(struct pmic_id) * (len_pmic_id / PMIC_ID_SIZE));
-			ASSERT(pmic_data);
+			if (!pmic_data) {
+				DEBUG((EFI_D_ERROR, "Failed to allocate memory for pmic_data\n"));
+				return FALSE;
+			}
 		}
 		i = 0;
 
@@ -222,7 +241,10 @@
 			}
 
 			dt_entry_array = (struct dt_entry*) AllocatePool(sizeof(struct dt_entry) * num_entries);
-			ASSERT(dt_entry_array);
+			if (!dt_entry_array) {
+				DEBUG((EFI_D_ERROR, "Failed to allocate memory for dt_entry_array\n"));
+				return FALSE;
+			}
 
 			/* If we have '<X>; <Y>; <Z>' as platform data & '<A>; <B>; <C>' as board data.
 			 * Then dt entry should look like
@@ -360,7 +382,9 @@
 			break;
 		dtb_size = fdt_totalsize(&dtb_hdr);
 
-		DeviceTreeCompatible(dtb, dtb_size, dt_entry_queue);
+		if (!DeviceTreeCompatible(dtb, dtb_size, dt_entry_queue)) {
+			DEBUG((EFI_D_VERBOSE, "Error while DTB parse continue with next DTB\n"));
+		}
 
 		/* goto the next device tree if any */
 		dtb += dtb_size;
@@ -495,6 +519,11 @@
 			((cur_dt_entry->pmic_rev[3] & 0x00ffff00) <= (BoardPmicTarget(3) & 0x00ffff00))) {
 
 		dt_node_tmp = dt_entry_list_init();
+		if (!dt_node_tmp) {
+			DEBUG((EFI_D_ERROR, "dt_node_tmp is NULL\n"));
+			return 0;
+		}
+
 		CopyMem((VOID *)dt_node_tmp->dt_entry_m,(VOID *)cur_dt_entry, sizeof(struct dt_entry));
 
 		DEBUG((EFI_D_VERBOSE, "Add DTB entry 0x%x/%08x/0x%08x/0x%x/0x%x/0x%x/0x%x/0x%x/0x%x/0x%x\n",