From 5a44176047595120c42e9971b718d9f78110ef1b Mon Sep 17 00:00:00 2001 From: Shaunak Saha Date: Tue, 12 Dec 2017 10:21:50 -0800 Subject: soc/intel/common/block: Check for NULL before dereference We check for NULL from the return of function acpi_device_path before passing it to acpigen_write_scope to avoid NULL pointer dereference. Change-Id: I997461c9b639acc3c323263d304333d3a894267c Found-by: Klockworks Signed-off-by: Shaunak Saha Reviewed-on: https://review.coreboot.org/23094 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel Reviewed-by: Aaron Durbin --- src/soc/intel/common/block/i2c/i2c.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/soc') diff --git a/src/soc/intel/common/block/i2c/i2c.c b/src/soc/intel/common/block/i2c/i2c.c index 7200771a5a..f2154da3f6 100644 --- a/src/soc/intel/common/block/i2c/i2c.c +++ b/src/soc/intel/common/block/i2c/i2c.c @@ -122,6 +122,7 @@ static void lpss_i2c_acpi_fill_ssdt(struct device *dev) I2C_SPEED_HIGH, }; int i, bus; + const char *path; if (!dev->enabled) return; @@ -140,7 +141,11 @@ static void lpss_i2c_acpi_fill_ssdt(struct device *dev) if (!dw_i2c_addr) return; - acpigen_write_scope(acpi_device_path(dev)); + path = acpi_device_path(dev); + if (!path) + return; + + acpigen_write_scope(path); /* Report timing values for the OS driver */ for (i = 0; i < DW_I2C_SPEED_CONFIG_COUNT; i++) { -- cgit v1.2.3