fsp 1.0 systems: Check for NULL when saving HobListPtr
Die if cbmem_add can't allocate memory for the hob pointer. This shouldn't ever happen, but it's a reasonable check. - fsp_broadwell_de already had a check, but it returned to someplace inside the FSP. Just die instead. Change-Id: Ieef8d6ab81aab0ec3d52b729e34566bb34ee0623 Found-by: Coverity Scan #1291162 Signed-off-by: Martin Roth <martinroth@google.com> Reviewed-on: https://review.coreboot.org/18092 Tested-by: build bot (Jenkins) Reviewed-by: Werner Zeh <werner.zeh@siemens.com>
This commit is contained in:
parent
feb4ef6d92
commit
4fb64d0b88
|
@ -298,7 +298,9 @@ void romstage_main_continue(EFI_STATUS status, VOID *HobListPtr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Save the HOB pointer in CBMEM to be used in ramstage. */
|
/* Save the HOB pointer in CBMEM to be used in ramstage. */
|
||||||
cbmem_hob_ptr = cbmem_add (CBMEM_ID_HOB_POINTER, sizeof(*HobListPtr));
|
cbmem_hob_ptr = cbmem_add(CBMEM_ID_HOB_POINTER, sizeof(*HobListPtr));
|
||||||
|
if (cbmem_hob_ptr == NULL)
|
||||||
|
die("Could not allocate cbmem for HOB pointer");
|
||||||
*(u32*)cbmem_hob_ptr = (u32)HobListPtr;
|
*(u32*)cbmem_hob_ptr = (u32)HobListPtr;
|
||||||
post_code(0x4f);
|
post_code(0x4f);
|
||||||
|
|
||||||
|
|
|
@ -252,7 +252,9 @@ void romstage_main_continue(EFI_STATUS status, void *hob_list_ptr)
|
||||||
cbmem_was_initted = !cbmem_recovery(prev_sleep_state == ACPI_S3);
|
cbmem_was_initted = !cbmem_recovery(prev_sleep_state == ACPI_S3);
|
||||||
|
|
||||||
/* Save the HOB pointer in CBMEM to be used in ramstage*/
|
/* Save the HOB pointer in CBMEM to be used in ramstage*/
|
||||||
cbmem_hob_ptr = cbmem_add (CBMEM_ID_HOB_POINTER, sizeof(*hob_list_ptr));
|
cbmem_hob_ptr = cbmem_add(CBMEM_ID_HOB_POINTER, sizeof(*hob_list_ptr));
|
||||||
|
if (cbmem_hob_ptr == NULL)
|
||||||
|
die("Could not allocate cbmem for HOB pointer");
|
||||||
*(u32*)cbmem_hob_ptr = (u32)hob_list_ptr;
|
*(u32*)cbmem_hob_ptr = (u32)hob_list_ptr;
|
||||||
post_code(0x4e);
|
post_code(0x4e);
|
||||||
|
|
||||||
|
|
|
@ -106,11 +106,9 @@ void romstage_main_continue(EFI_STATUS status, void *hob_list_ptr)
|
||||||
cbmem_was_initted = !cbmem_recovery(0);
|
cbmem_was_initted = !cbmem_recovery(0);
|
||||||
|
|
||||||
/* Save the HOB pointer in CBMEM to be used in ramstage*/
|
/* Save the HOB pointer in CBMEM to be used in ramstage*/
|
||||||
cbmem_hob_ptr = cbmem_add (CBMEM_ID_HOB_POINTER, sizeof(*hob_list_ptr));
|
cbmem_hob_ptr = cbmem_add(CBMEM_ID_HOB_POINTER, sizeof(*hob_list_ptr));
|
||||||
if (cbmem_hob_ptr == NULL) {
|
if (cbmem_hob_ptr == NULL)
|
||||||
printk(BIOS_DEBUG, "Failed to save HOB pointer in CBMEM.\n");
|
die("Could not allocate cbmem for HOB pointer");
|
||||||
return;
|
|
||||||
}
|
|
||||||
*(u32 *)cbmem_hob_ptr = (u32)hob_list_ptr;
|
*(u32 *)cbmem_hob_ptr = (u32)hob_list_ptr;
|
||||||
|
|
||||||
/* Load the ramstage. */
|
/* Load the ramstage. */
|
||||||
|
|
|
@ -208,7 +208,9 @@ void romstage_main_continue(EFI_STATUS status, VOID *HobListPtr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Save the HOB pointer in CBMEM to be used in ramstage. */
|
/* Save the HOB pointer in CBMEM to be used in ramstage. */
|
||||||
cbmem_hob_ptr = cbmem_add (CBMEM_ID_HOB_POINTER, sizeof(HobListPtr));
|
cbmem_hob_ptr = cbmem_add(CBMEM_ID_HOB_POINTER, sizeof(HobListPtr));
|
||||||
|
if (cbmem_hob_ptr == NULL)
|
||||||
|
die("Could not allocate cbmem for HOB pointer");
|
||||||
*(uint32_t*)cbmem_hob_ptr = (uint32_t)HobListPtr;
|
*(uint32_t*)cbmem_hob_ptr = (uint32_t)HobListPtr;
|
||||||
post_code(0x4f);
|
post_code(0x4f);
|
||||||
|
|
||||||
|
|
|
@ -122,7 +122,9 @@ void romstage_main_continue(EFI_STATUS status, void *hob_list_ptr) {
|
||||||
cbmem_was_initted = !cbmem_recovery(0);
|
cbmem_was_initted = !cbmem_recovery(0);
|
||||||
|
|
||||||
/* Save the HOB pointer in CBMEM to be used in ramstage*/
|
/* Save the HOB pointer in CBMEM to be used in ramstage*/
|
||||||
cbmem_hob_ptr = cbmem_add (CBMEM_ID_HOB_POINTER, sizeof(*hob_list_ptr));
|
cbmem_hob_ptr = cbmem_add(CBMEM_ID_HOB_POINTER, sizeof(*hob_list_ptr));
|
||||||
|
if (cbmem_hob_ptr == NULL)
|
||||||
|
die("Could not allocate cbmem for HOB pointer");
|
||||||
*(u32*)cbmem_hob_ptr = (u32)hob_list_ptr;
|
*(u32*)cbmem_hob_ptr = (u32)hob_list_ptr;
|
||||||
post_code(0x4e);
|
post_code(0x4e);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue