John Zhao has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/42835 )
Change subject: src/drivers/intel: Avoid NULL pointer dereference ......................................................................
src/drivers/intel: 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 1429979, 1429982 TEST=Built and boot up to kernel.
Signed-off-by: John Zhao john.zhao@intel.com Change-Id: If17d12861f562dc0d6c98a5c91a9d3c0360ca2c9 --- M src/drivers/intel/pmc_mux/con/con.c M src/drivers/intel/pmc_mux/mux.c 2 files changed, 17 insertions(+), 4 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/35/42835/1
diff --git a/src/drivers/intel/pmc_mux/con/con.c b/src/drivers/intel/pmc_mux/con/con.c index 08c38e8..ad95905 100644 --- a/src/drivers/intel/pmc_mux/con/con.c +++ b/src/drivers/intel/pmc_mux/con/con.c @@ -29,13 +29,20 @@ { struct drivers_intel_pmc_mux_con_config *config = dev->chip_info; struct acpi_dp *dsd; + const char *scope; + const char *name;
if (!dev->enabled) return;
/* Reference the existing scope and write CONx device */ - acpigen_write_scope(acpi_device_scope(dev)); - acpigen_write_device(acpi_device_name(dev)); + scope = acpi_device_scope(dev); + name = acpi_device_name(dev); + if (!scope || !name) + return; + + acpigen_write_scope(scope); + acpigen_write_device(name);
acpigen_write_name_integer("_ADR", dev->path.generic.id);
diff --git a/src/drivers/intel/pmc_mux/mux.c b/src/drivers/intel/pmc_mux/mux.c index 29ed1a9..e209915 100644 --- a/src/drivers/intel/pmc_mux/mux.c +++ b/src/drivers/intel/pmc_mux/mux.c @@ -13,8 +13,14 @@
static void mux_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", TGL_PMC_MUX_HID); acpigen_write_name_string("_DDN", dev->chip_ops->name);
Paul Menzel has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/42835 )
Change subject: src/drivers/intel: Avoid NULL pointer dereference ......................................................................
Patch Set 1:
(1 comment)
Thank you for taking care of these.
https://review.coreboot.org/c/coreboot/+/42835/1//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/42835/1//COMMIT_MSG@13 PS1, Line 13: BUG=CID 1429979, 1429982 Good idea to use BUG= tag, but common is the Found-by tag.
Please look through `git log --grep 'Found-by:'` for the format.
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/+/42835
to look at the new patch set (#2).
Change subject: src/drivers/intel: Avoid NULL pointer dereference ......................................................................
src/drivers/intel: 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 1429979, 1429982 TEST=Built and boot up to kernel.
Signed-off-by: John Zhao john.zhao@intel.com Change-Id: If17d12861f562dc0d6c98a5c91a9d3c0360ca2c9 --- M src/drivers/intel/pmc_mux/con/con.c M src/drivers/intel/pmc_mux/mux.c 2 files changed, 17 insertions(+), 4 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/35/42835/2
John Zhao has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/42835 )
Change subject: src/drivers/intel: Avoid NULL pointer dereference ......................................................................
Patch Set 2:
(1 comment)
https://review.coreboot.org/c/coreboot/+/42835/1//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/42835/1//COMMIT_MSG@13 PS1, Line 13: BUG=CID 1429979, 1429982
Good idea to use BUG= tag, but common is the Found-by tag. […]
Ack
Wonkyu Kim has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/42835 )
Change subject: src/drivers/intel: Avoid NULL pointer dereference ......................................................................
Patch Set 2: Code-Review+1
Patrick Rudolph has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/42835 )
Change subject: src/drivers/intel: Avoid NULL pointer dereference ......................................................................
Patch Set 2: Code-Review+2
Tim Wawrzynczak has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/42835 )
Change subject: src/drivers/intel: Avoid NULL pointer dereference ......................................................................
Patch Set 2: Code-Review+2
Patrick Georgi has submitted this change. ( https://review.coreboot.org/c/coreboot/+/42835 )
Change subject: src/drivers/intel: Avoid NULL pointer dereference ......................................................................
src/drivers/intel: 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 1429979, 1429982 TEST=Built and boot up to kernel.
Signed-off-by: John Zhao john.zhao@intel.com Change-Id: If17d12861f562dc0d6c98a5c91a9d3c0360ca2c9 Reviewed-on: https://review.coreboot.org/c/coreboot/+/42835 Reviewed-by: Wonkyu Kim wonkyu.kim@intel.com Reviewed-by: Patrick Rudolph siro@das-labor.org Reviewed-by: Tim Wawrzynczak twawrzynczak@chromium.org Tested-by: build bot (Jenkins) no-reply@coreboot.org --- M src/drivers/intel/pmc_mux/con/con.c M src/drivers/intel/pmc_mux/mux.c 2 files changed, 17 insertions(+), 4 deletions(-)
Approvals: build bot (Jenkins): Verified Patrick Rudolph: Looks good to me, approved Wonkyu Kim: Looks good to me, but someone else must approve Tim Wawrzynczak: Looks good to me, approved
diff --git a/src/drivers/intel/pmc_mux/con/con.c b/src/drivers/intel/pmc_mux/con/con.c index 08c38e8..ad95905 100644 --- a/src/drivers/intel/pmc_mux/con/con.c +++ b/src/drivers/intel/pmc_mux/con/con.c @@ -29,13 +29,20 @@ { struct drivers_intel_pmc_mux_con_config *config = dev->chip_info; struct acpi_dp *dsd; + const char *scope; + const char *name;
if (!dev->enabled) return;
/* Reference the existing scope and write CONx device */ - acpigen_write_scope(acpi_device_scope(dev)); - acpigen_write_device(acpi_device_name(dev)); + scope = acpi_device_scope(dev); + name = acpi_device_name(dev); + if (!scope || !name) + return; + + acpigen_write_scope(scope); + acpigen_write_device(name);
acpigen_write_name_integer("_ADR", dev->path.generic.id);
diff --git a/src/drivers/intel/pmc_mux/mux.c b/src/drivers/intel/pmc_mux/mux.c index 29ed1a9..e209915 100644 --- a/src/drivers/intel/pmc_mux/mux.c +++ b/src/drivers/intel/pmc_mux/mux.c @@ -13,8 +13,14 @@
static void mux_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", TGL_PMC_MUX_HID); acpigen_write_name_string("_DDN", dev->chip_ops->name);