Angel Pons has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/49744 )
Change subject: device: Prevent using `mmconf_resource` with invalid values ......................................................................
device: Prevent using `mmconf_resource` with invalid values
Use the `dead_code` macro to fail builds where the function is used and either MMCONF_BASE_ADDRESS or MMCONF_BUS_NUMBER have invalid values.
Change-Id: I4473268016ed511aa5c4930a71977e722e34162a Signed-off-by: Angel Pons th3fanbus@gmail.com --- M src/device/device_util.c 1 file changed, 4 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/44/49744/1
diff --git a/src/device/device_util.c b/src/device/device_util.c index 0bce26a..25f3bf1 100644 --- a/src/device/device_util.c +++ b/src/device/device_util.c @@ -1,5 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */
+#include <assert.h> #include <console/console.h> #include <device/device.h> #include <device/path.h> @@ -877,6 +878,9 @@
void mmconf_resource(struct device *dev, unsigned long index) { + if (CONFIG_MMCONF_BASE_ADDRESS <= 0 || CONFIG_MMCONF_BUS_NUMBER <= 0) + dead_code(); + struct resource *resource = new_resource(dev, index); mmconf_resource_init(resource, CONFIG_MMCONF_BASE_ADDRESS, CONFIG_MMCONF_BUS_NUMBER);