Add additional error handling to pcidev_readbar() callers

This is mostly a leftover of Niklas' "remove exit call from pcidev_init" patch.
While not explicitly necessary detecting errors early is usually a good idea.

Corresponding to flashrom svn r1718.

Signed-off-by: Niklas Söderlund <>
Signed-off-by: Stefan Tauner <>
Acked-by: Stefan Tauner <>
diff --git a/gfxnvidia.c b/gfxnvidia.c
index 8f3aa44..d3ee14e 100644
--- a/gfxnvidia.c
+++ b/gfxnvidia.c
@@ -90,6 +90,9 @@
 		return 1;
 	io_base_addr = pcidev_readbar(dev, PCI_BASE_ADDRESS_0);
+	if (!io_base_addr)
+		return 1;
 	io_base_addr += 0x300000;
 	msg_pinfo("Detected NVIDIA I/O base address: 0x%x.\n", io_base_addr);