From 4fb64d0b880c698cba92f5ec2e4d39f3bdb92fc6 Mon Sep 17 00:00:00 2001 From: Martin Roth Date: Tue, 10 Jan 2017 11:15:13 -0700 Subject: 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 Reviewed-on: https://review.coreboot.org/18092 Tested-by: build bot (Jenkins) Reviewed-by: Werner Zeh --- src/mainboard/intel/cougar_canyon2/romstage.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/mainboard/intel/cougar_canyon2') diff --git a/src/mainboard/intel/cougar_canyon2/romstage.c b/src/mainboard/intel/cougar_canyon2/romstage.c index 998528dc4f..bf5b738754 100644 --- a/src/mainboard/intel/cougar_canyon2/romstage.c +++ b/src/mainboard/intel/cougar_canyon2/romstage.c @@ -298,7 +298,9 @@ void romstage_main_continue(EFI_STATUS status, VOID *HobListPtr) { } /* 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; post_code(0x4f); -- cgit v1.2.3