]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EmbeddedPkg/Drivers/FdtPlatformDxe/FdtPlatform.c
EmbeddedPkg: import Lan91x Ethernet controller driver
[mirror_edk2.git] / EmbeddedPkg / Drivers / FdtPlatformDxe / FdtPlatform.c
index b6f5c3e58d3ae1e20b2e5d0d2e932419f4bc01ba..b4be2a078991f0deccf1aa94f1b98ca6c00aa95f 100644 (file)
@@ -94,15 +94,16 @@ InstallFdt (
     goto Error;\r
   }\r
 \r
-  // Check the FDT header is valid. We only make this check in DEBUG mode in\r
-  // case the FDT header change on production device and this ASSERT() becomes\r
-  // not valid.\r
-  ASSERT (fdt_check_header ((VOID*)(UINTN)FdtBlobBase) == 0);\r
-\r
   //\r
-  // Ensure the Size of the Device Tree is smaller than the size of the read file\r
+  // Ensure that the FDT header is valid and that the Size of the Device Tree\r
+  // is smaller than the size of the read file\r
   //\r
-  ASSERT ((UINTN)fdt_totalsize ((VOID*)(UINTN)FdtBlobBase) <= FdtBlobSize);\r
+  if (fdt_check_header ((VOID*)(UINTN)FdtBlobBase) != 0 ||\r
+      (UINTN)fdt_totalsize ((VOID*)(UINTN)FdtBlobBase) > FdtBlobSize) {\r
+    DEBUG ((EFI_D_ERROR, "InstallFdt() - loaded FDT binary image seems corrupt\n"));\r
+    Status = EFI_LOAD_ERROR;\r
+    goto Error;\r
+  }\r
 \r
   //\r
   // Store the FDT as Runtime Service Data to prevent the Kernel from\r
@@ -169,9 +170,6 @@ FdtPlatformEntryPoint (
   // Install the Device Tree from its expected location\r
   //\r
   Status = RunFdtInstallation (NULL);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
 \r
   if (FeaturePcdGet (PcdOverridePlatformFdt) || FeaturePcdGet (PcdDumpFdtShellCommand)) {\r
     //\r