QcomModulePkg: Validate ddr header version before validating its fields
Do not check validity of ddr rank and channel before checking
ddr header version as these fields might not be present with older
ddr header version and we end up failing updating DT and that
could result in bootup failure.
Fix it by moving the ddr rank/channel validity check after checking
its ddr header version validity.
Change-Id: Iace5a776cbb00cab701517e1fc9b16db39f7661e
diff --git a/QcomModulePkg/Library/BootLib/UpdateDeviceTree.c b/QcomModulePkg/Library/BootLib/UpdateDeviceTree.c
index cf2ca6f..80dd9f8 100644
--- a/QcomModulePkg/Library/BootLib/UpdateDeviceTree.c
+++ b/QcomModulePkg/Library/BootLib/UpdateDeviceTree.c
@@ -71,6 +71,24 @@
}
STATIC EFI_STATUS
+ValidateDdrRankChannel (struct ddr_details_entry_info *DdrInfo)
+{
+ if (DdrInfo->num_channels > MAX_CHANNELS) {
+ DEBUG ((EFI_D_ERROR, "ERROR: Number of channels is over the limit\n"));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ for (UINT8 Chan = 0; Chan < DdrInfo->num_channels; Chan++) {
+ if (DdrInfo->num_ranks[Chan] > MAX_RANKS) {
+ DEBUG ((EFI_D_ERROR, "ERROR: Number of ranks is over the limit\n"));
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+
+ return EFI_SUCCESS;
+}
+
+STATIC EFI_STATUS
GetDDRInfo (struct ddr_details_entry_info *DdrInfo,
UINT64 *Revision)
{
@@ -92,17 +110,6 @@
return Status;
}
- if (DdrInfo->num_channels > MAX_CHANNELS) {
- DEBUG ((EFI_D_ERROR, "ERROR: Number of channels is over the limit\n"));
- return EFI_INVALID_PARAMETER;
- }
-
- for (UINT8 Chan = 0; Chan < DdrInfo->num_channels; Chan++) {
- if (DdrInfo->num_ranks[Chan] > MAX_RANKS) {
- DEBUG ((EFI_D_ERROR, "ERROR: Number of ranks is over the limit\n"));
- return EFI_INVALID_PARAMETER;
- }
- }
*Revision = DdrInfoIf->Revision;
DEBUG ((EFI_D_VERBOSE, "DDR Header Revision =0x%x\n", *Revision));
return Status;
@@ -559,6 +566,11 @@
"ddr_device_rank, HBB not supported in Revision=0x%x\n",
Revision));
} else {
+ Status = ValidateDdrRankChannel (DdrInfo);
+ if (Status != EFI_SUCCESS) {
+ goto OutofUpdateRankChannel;
+ }
+
DEBUG ((EFI_D_VERBOSE, "DdrInfo->num_channels:%d\n",
DdrInfo->num_channels));
for (UINT8 Chan = 0; Chan < DdrInfo->num_channels; Chan++) {
@@ -599,6 +611,8 @@
}
}
+OutofUpdateRankChannel:
+
UpdateSplashMemInfo (fdt);
/* Get offset of the chosen node */