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>
diff --git a/src/soc/intel/common/block/i2c/i2c.c b/src/soc/intel/common/block/i2c/i2c.c
index 7200771..f2154da 100644
--- a/src/soc/intel/common/block/i2c/i2c.c
+++ b/src/soc/intel/common/block/i2c/i2c.c
@@ -122,6 +122,7 @@
 		I2C_SPEED_HIGH,
 	};
 	int i, bus;
+	const char *path;
 
 	if (!dev->enabled)
 		return;
@@ -140,7 +141,11 @@
 	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++) {