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 <shaunak.saha@intel.com>
Reviewed-on: https://review.coreboot.org/23094
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
Shaunak Saha 2017-12-12 10:21:50 -08:00 committed by Martin Roth
parent e1a75d4a94
commit 5a44176047
1 changed files with 6 additions and 1 deletions

View File

@ -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++) {