summaryrefslogtreecommitdiff
path: root/src/superio/nuvoton
diff options
context:
space:
mode:
authorJohn Zhao <john.zhao@intel.com>2020-06-26 10:38:42 -0700
committerPatrick Georgi <pgeorgi@google.com>2020-07-12 19:40:53 +0000
commit8f5fbb0f26b8270ebdbec87925aa2b1604c83251 (patch)
tree4d3e8e6e92fe33f8552a3fd9e6af5a0454bdd267 /src/superio/nuvoton
parent4a924dce995cd30a845bc75f41cdb00458b27244 (diff)
superio/nuvoton: Avoid NULL pointer dereference
Coverity detects dereferencing a pointer that might be "NULL" when calling acpigen_write_scope. Add sanity check for scope to prevent NULL pointer dereference. Found-by: Coverity CID 1420207 Signed-off-by: John Zhao <john.zhao@intel.com> Change-Id: Icc253c63aadef1c0ecb116a38b608f64f80abc79 Reviewed-on: https://review.coreboot.org/c/coreboot/+/42839 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Diffstat (limited to 'src/superio/nuvoton')
-rw-r--r--src/superio/nuvoton/npcd378/superio.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/superio/nuvoton/npcd378/superio.c b/src/superio/nuvoton/npcd378/superio.c
index 628bd4e379..b7f98af66b 100644
--- a/src/superio/nuvoton/npcd378/superio.c
+++ b/src/superio/nuvoton/npcd378/superio.c
@@ -325,7 +325,11 @@ static void npcd378_ssdt_pwr(const struct device *dev)
acpigen_pop_len(); /* Pop Scope */
/* Inject into parent: */
- acpigen_write_scope(acpi_device_scope(dev));
+ if (!scope) {
+ printk(BIOS_ERR, "%s: Missing ACPI path/scope\n", dev_path(dev));
+ return;
+ }
+ acpigen_write_scope(scope);
acpigen_write_name_integer("MSFG", 1);
acpigen_write_name_integer("KBFG", 1);
@@ -404,6 +408,9 @@ static void npcd378_ssdt_pwr(const struct device *dev)
static void npcd378_fill_ssdt_generator(const struct device *dev)
{
+ if (!dev)
+ return;
+
superio_common_fill_ssdt_generator(dev);
switch (dev->path.pnp.device) {