diff options
author | Martin Roth <martinroth@google.com> | 2017-01-10 11:15:13 -0700 |
---|---|---|
committer | Martin Roth <martinroth@google.com> | 2017-01-12 17:19:26 +0100 |
commit | 4fb64d0b880c698cba92f5ec2e4d39f3bdb92fc6 (patch) | |
tree | 1fd1c6db679608dae1e2c407cd34b0cfcdb03443 /src/soc | |
parent | feb4ef6d92bdbcd12b2cd97b6446fb64b76cfef4 (diff) |
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>
Diffstat (limited to 'src/soc')
-rw-r--r-- | src/soc/intel/fsp_baytrail/romstage/romstage.c | 4 | ||||
-rw-r--r-- | src/soc/intel/fsp_broadwell_de/romstage/romstage.c | 8 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/soc/intel/fsp_baytrail/romstage/romstage.c b/src/soc/intel/fsp_baytrail/romstage/romstage.c index 9d204d16e2..f8d985eaea 100644 --- a/src/soc/intel/fsp_baytrail/romstage/romstage.c +++ b/src/soc/intel/fsp_baytrail/romstage/romstage.c @@ -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); /* 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; post_code(0x4e); diff --git a/src/soc/intel/fsp_broadwell_de/romstage/romstage.c b/src/soc/intel/fsp_broadwell_de/romstage/romstage.c index 49d9a94919..5754ec00a5 100644 --- a/src/soc/intel/fsp_broadwell_de/romstage/romstage.c +++ b/src/soc/intel/fsp_broadwell_de/romstage/romstage.c @@ -106,11 +106,9 @@ void romstage_main_continue(EFI_STATUS status, void *hob_list_ptr) cbmem_was_initted = !cbmem_recovery(0); /* Save the HOB pointer in CBMEM to be used in ramstage*/ - cbmem_hob_ptr = cbmem_add (CBMEM_ID_HOB_POINTER, sizeof(*hob_list_ptr)); - if (cbmem_hob_ptr == NULL) { - printk(BIOS_DEBUG, "Failed to save HOB pointer in CBMEM.\n"); - return; - } + 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; /* Load the ramstage. */ |