summaryrefslogtreecommitdiff
path: root/src/device/device.c
diff options
context:
space:
mode:
authorJohn Zhao <john.zhao@intel.com>2019-05-29 18:12:01 -0700
committerPatrick Georgi <pgeorgi@google.com>2019-06-03 13:25:25 +0000
commit2deb5fb3b07e07ee3d0d142723e2a25f5982d417 (patch)
treee522061361efe4130f9df8693d7e902a42fd5f56 /src/device/device.c
parent62ddc491cf8c8c6412177d2866bec89c6f4906dc (diff)
src/device: Prevent attack on null pointer dereference
Clang Static Analyzer version 8.0.0 detects access to field dev results in a dereference of a null pointer which is loaded from variable bus. Add sanity check for pointer bus to prevent null pointer dereference. TEST=Built and boot up to kernel. Change-Id: I084906c33065eaa834f50c545efcfab620658ec9 Signed-off-by: John Zhao <john.zhao@intel.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/33101 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Lijian Zhao <lijian.zhao@intel.com>
Diffstat (limited to 'src/device/device.c')
-rw-r--r--src/device/device.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/device/device.c b/src/device/device.c
index 1b4255bffe..17cd8f4ab8 100644
--- a/src/device/device.c
+++ b/src/device/device.c
@@ -340,6 +340,9 @@ static void compute_resources(struct bus *bus, struct resource *bridge,
resource_t base;
base = round(bridge->base, bridge->align);
+ if (!bus)
+ return;
+
printk(BIOS_SPEW, "%s %s: base: %llx size: %llx align: %d gran: %d"
" limit: %llx\n", dev_path(bus->dev), resource2str(bridge),
base, bridge->size, bridge->align,
@@ -484,6 +487,9 @@ static void allocate_resources(struct bus *bus, struct resource *bridge,
resource_t base;
base = bridge->base;
+ if (!bus)
+ return;
+
printk(BIOS_SPEW, "%s %s: base:%llx size:%llx align:%d gran:%d "
"limit:%llx\n", dev_path(bus->dev),
resource2str(bridge),