platform: msm_shared: move size overlap check
Move dtb size overlap check before copying dtb to tags memory
Change-Id: Id8bc28d7e0a54c7a94d05fffc3bbb4c95ff67e26
CRs-Fixed: 967992
diff --git a/platform/msm_shared/dev_tree.c b/platform/msm_shared/dev_tree.c
index 4903d5c..6a73826 100755
--- a/platform/msm_shared/dev_tree.c
+++ b/platform/msm_shared/dev_tree.c
@@ -486,11 +486,6 @@
break;
dtb_size = fdt_totalsize(&dtb_hdr);
- if (check_aboot_addr_range_overlap((uintptr_t)tags, dtb_size)) {
- dprintf(CRITICAL, "Tags addresses overlap with aboot addresses.\n");
- return NULL;
- }
-
dev_tree_compatible(dtb, dtb_size, dt_entry_queue);
/* goto the next device tree if any */
@@ -521,6 +516,10 @@
}
if(bestmatch_tag) {
+ if (check_aboot_addr_range_overlap((uintptr_t)tags, bestmatch_tag_size)) {
+ dprintf(CRITICAL, "Tags addresses overlap with aboot addresses.\n");
+ return NULL;
+ }
memcpy(tags, bestmatch_tag, bestmatch_tag_size);
/* clear out the old DTB magic so kernel doesn't find it */
*((uint32_t *)(kernel + app_dtb_offset)) = 0;