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
// 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