From f6f1f734ee1b6322ebf3913743d5c526be65dc42 Mon Sep 17 00:00:00 2001 From: John Zhao Date: Fri, 26 Jun 2020 10:00:02 -0700 Subject: soc/amd/picasso: 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 1429980 TEST=None Signed-off-by: John Zhao Change-Id: I6214fb83bccb19fe4edad65ce6b862815b8dcec6 Reviewed-on: https://review.coreboot.org/c/coreboot/+/42837 Reviewed-by: Aaron Durbin Tested-by: build bot (Jenkins) --- src/soc/amd/picasso/root_complex.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/soc/amd/picasso') diff --git a/src/soc/amd/picasso/root_complex.c b/src/soc/amd/picasso/root_complex.c index 036ff00ccb..1c069282af 100644 --- a/src/soc/amd/picasso/root_complex.c +++ b/src/soc/amd/picasso/root_complex.c @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ #include +#include #include #include #include @@ -134,14 +135,13 @@ static void read_resources(struct device *dev) static void root_complex_fill_ssdt(const struct device *device) { msr_t msr; + const char *scope; - if (!device) { - printk(BIOS_ERR, "%s: device is NULL! ACPI SSDT will be incomplete.\n", - __func__); - return; - } + assert(device); - acpigen_write_scope(acpi_device_scope(device)); + scope = acpi_device_scope(device); + assert(scope); + acpigen_write_scope(scope); msr = rdmsr(TOP_MEM); acpigen_write_name_dword("TOM1", msr.lo); -- cgit v1.2.3