From e311f94279de87f31b94d47cc46c43f0dd7741ef Mon Sep 17 00:00:00 2001 From: Paul Wise Date: Thu, 4 May 2017 14:13:38 +0800 Subject: intelmetool: handle failures to mmap MEI memory Fixes crashes when there is an error mapping memory. Error mapping physical memory 0x0000004275159040 [0x4000] ERRNO=1 Segmentation fault (core dumped) Change-Id: I5becc0c2870dd97297c4e8d1b101b95b31792ca7 Signed-off-by: Paul Wise Reviewed-on: https://review.coreboot.org/19562 Tested-by: build bot (Jenkins) Reviewed-by: Philipp Deppenwiese Reviewed-by: Paul Menzel --- util/intelmetool/intelmetool.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'util/intelmetool/intelmetool.c') diff --git a/util/intelmetool/intelmetool.c b/util/intelmetool/intelmetool.c index 62dc4d92c4..11c2120c16 100644 --- a/util/intelmetool/intelmetool.c +++ b/util/intelmetool/intelmetool.c @@ -83,6 +83,10 @@ static void dump_me_memory() { uint8_t *dump; dump = map_physical_exact((off_t)me_clone, (void *)me_clone, 0x2000000); + if (dump == NULL) { + printf("Could not map ME memory\n"); + return; + } zeroit(dump, 0x2000000); printf("Send magic command for memory clone\n"); @@ -210,6 +214,12 @@ static int activate_me() { rcba_phys = pci_read_long(sb, 0xf0) & 0xfffffffe; rcba = map_physical((off_t)rcba_phys, size); + if (rcba == NULL) { + printf("Could not map MEI PCI device memory\n"); + pci_free_dev(sb); + pci_cleanup(pacc); + return 1; + } //printf("RCBA at 0x%08" PRIx32 "\n", (uint32_t)rcba_phys); fd2 = *(uint32_t *)(rcba + FD2); -- cgit v1.2.3