[coreboot-gerrit] Change in coreboot[master]: util/intelmetool: Check for NULL return from pci_lookup_name

Youness Alaoui (Code Review) gerrit at coreboot.org
Mon Apr 3 20:39:06 CEST 2017


Youness Alaoui has uploaded a new change for review. ( https://review.coreboot.org/19089 )

Change subject: util/intelmetool: Check for NULL return from pci_lookup_name
......................................................................

util/intelmetool: Check for NULL return from pci_lookup_name

pci_lookup_name might return NULL from using format_name internally
which would cause a crash when trying to print that value. We
check for NULL and print a more appropriate value in that case.

Change-Id: I499f0b5e1681f3926df0d8a325aab2c666ebd632
Signed-off-by: Youness Alaoui <youness.alaoui at puri.sm>
---
M util/intelmetool/intelmetool.c
1 file changed, 4 insertions(+), 0 deletions(-)


  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/89/19089/1

diff --git a/util/intelmetool/intelmetool.c b/util/intelmetool/intelmetool.c
index c49c635..d6fd0fe 100644
--- a/util/intelmetool/intelmetool.c
+++ b/util/intelmetool/intelmetool.c
@@ -119,6 +119,8 @@
 		pci_fill_info(dev, PCI_FILL_IDENT | PCI_FILL_BASES | PCI_FILL_SIZES | PCI_FILL_CLASS);
 		name = pci_lookup_name(pacc, namebuf, sizeof(namebuf),
 			PCI_LOOKUP_DEVICE, dev->vendor_id, dev->device_id);
+		if (name == NULL)
+			name = "<unknown>";
 		if (dev->vendor_id == 0x8086) {
 			if (PCI_DEV_HAS_ME_DISABLE(dev->device_id)) {
 				printf(CGRN "Good news, you have a `%s` so ME is present but can be disabled, continuing...\n\n" RESET, name);
@@ -242,6 +244,8 @@
 		exit(1);
 	}
 
+	if (name == NULL)
+		name = "<unknown>";
 	printf("MEI found: [%x:%x] %s\n\n", dev->vendor_id, dev->device_id, name);
 	stat = pci_read_long(dev, 0x40);
 	printf("ME Status   : 0x%x\n", stat);

-- 
To view, visit https://review.coreboot.org/19089
To unsubscribe, visit https://review.coreboot.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I499f0b5e1681f3926df0d8a325aab2c666ebd632
Gerrit-PatchSet: 1
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Owner: Youness Alaoui <snifikino at gmail.com>



More information about the coreboot-gerrit mailing list