John Zhao has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/42836 )
Change subject: soc/intel/tigerlake: Avoid NULL pointer dereference ......................................................................
soc/intel/tigerlake: Avoid NULL pointer dereference
Coverity detects dereferencing pointers that might be "NULL" when calling acpigen_write_scope and acpigen_write_device. Add sanity check for both of scope and name to prevent NULL pointer dereference.
BUG=CID 1429981 TEST=Built and boot up to kernel.
Signed-off-by: John Zhao john.zhao@intel.com Change-Id: Iea3801585e8c294fb889a8137b534bb932696025 --- M src/soc/intel/tigerlake/pmc.c 1 file changed, 7 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/36/42836/1
diff --git a/src/soc/intel/tigerlake/pmc.c b/src/soc/intel/tigerlake/pmc.c index 4d89870..561447d 100644 --- a/src/soc/intel/tigerlake/pmc.c +++ b/src/soc/intel/tigerlake/pmc.c @@ -101,8 +101,13 @@
static void soc_pmc_fill_ssdt(const struct device *dev) { - acpigen_write_scope(acpi_device_scope(dev)); - acpigen_write_device(acpi_device_name(dev)); + const char *scope = acpi_device_scope(dev); + const char *name = acpi_device_name(dev); + if (!scope || !name) + return; + + acpigen_write_scope(scope); + acpigen_write_device(name);
acpigen_write_name_string("_HID", PMC_HID); acpigen_write_name_string("_DDN", "Intel(R) Tiger Lake IPC Controller");
Hello build bot (Jenkins), Wonkyu Kim, Duncan Laurie, Tim Wawrzynczak, Patrick Rudolph,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/42836
to look at the new patch set (#2).
Change subject: soc/intel/tigerlake: Avoid NULL pointer dereference ......................................................................
soc/intel/tigerlake: Avoid NULL pointer dereference
Coverity detects dereferencing pointers that might be "NULL" when calling acpigen_write_scope and acpigen_write_device. Add sanity check for both of scope and name to prevent NULL pointer dereference.
Found-by: Coverity CID 1429981 TEST=Built and boot up to kernel.
Signed-off-by: John Zhao john.zhao@intel.com Change-Id: Iea3801585e8c294fb889a8137b534bb932696025 --- M src/soc/intel/tigerlake/pmc.c 1 file changed, 7 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/36/42836/2
Tim Wawrzynczak has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/42836 )
Change subject: soc/intel/tigerlake: Avoid NULL pointer dereference ......................................................................
Patch Set 2: Code-Review+2
Patrick Georgi has submitted this change. ( https://review.coreboot.org/c/coreboot/+/42836 )
Change subject: soc/intel/tigerlake: Avoid NULL pointer dereference ......................................................................
soc/intel/tigerlake: Avoid NULL pointer dereference
Coverity detects dereferencing pointers that might be "NULL" when calling acpigen_write_scope and acpigen_write_device. Add sanity check for both of scope and name to prevent NULL pointer dereference.
Found-by: Coverity CID 1429981 TEST=Built and boot up to kernel.
Signed-off-by: John Zhao john.zhao@intel.com Change-Id: Iea3801585e8c294fb889a8137b534bb932696025 Reviewed-on: https://review.coreboot.org/c/coreboot/+/42836 Reviewed-by: Tim Wawrzynczak twawrzynczak@chromium.org Tested-by: build bot (Jenkins) no-reply@coreboot.org --- M src/soc/intel/tigerlake/pmc.c 1 file changed, 7 insertions(+), 2 deletions(-)
Approvals: build bot (Jenkins): Verified Tim Wawrzynczak: Looks good to me, approved
diff --git a/src/soc/intel/tigerlake/pmc.c b/src/soc/intel/tigerlake/pmc.c index b98cbbe..8fcbe50 100644 --- a/src/soc/intel/tigerlake/pmc.c +++ b/src/soc/intel/tigerlake/pmc.c @@ -99,8 +99,13 @@
static void soc_pmc_fill_ssdt(const struct device *dev) { - acpigen_write_scope(acpi_device_scope(dev)); - acpigen_write_device(acpi_device_name(dev)); + const char *scope = acpi_device_scope(dev); + const char *name = acpi_device_name(dev); + if (!scope || !name) + return; + + acpigen_write_scope(scope); + acpigen_write_device(name);
acpigen_write_name_string("_HID", PMC_HID); acpigen_write_name_string("_DDN", "Intel(R) Tiger Lake IPC Controller");