From 2a1ae05316db8d70c8e15df4913b786b120ab615 Mon Sep 17 00:00:00 2001 From: Huan Truong Date: Sun, 5 Mar 2017 02:24:51 -0600 Subject: util/intelmetool: Fix segfault on edge cases The intel ME checker tool would segfault if it reaches the end of the loop without having the dev pointer set. This happens when it gets to the end of the previous loop without knowing what to do with any of the devices it sees. This patch makes sure the pointer is not NULL before accessing it. Change-Id: Ia13191799d7e00185947f9df5188cb2666c43e2a Signed-off-by: Huan Truong Reviewed-on: https://review.coreboot.org/18573 Tested-by: build bot (Jenkins) Reviewed-by: Arthur Heymans Reviewed-by: Philipp Deppenwiese Reviewed-by: Paul Menzel --- util/intelmetool/intelmetool.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/util/intelmetool/intelmetool.c b/util/intelmetool/intelmetool.c index 70b23fbec2..45e8c8f7ba 100644 --- a/util/intelmetool/intelmetool.c +++ b/util/intelmetool/intelmetool.c @@ -137,7 +137,8 @@ static int pci_platform_scan() { } } - if (!PCI_DEV_HAS_ME_DISABLE(dev->device_id) && + if (dev != NULL && + !PCI_DEV_HAS_ME_DISABLE(dev->device_id) && !PCI_DEV_HAS_ME_DIFFICULT(dev->device_id) && !PCI_DEV_CAN_DISABLE_ME_IF_PRESENT(dev->device_id) && !PCI_DEV_ME_NOT_SURE(dev->device_id)) { -- cgit v1.2.3