Aaron Durbin has submitted this change. ( https://review.coreboot.org/c/coreboot/+/42837 )
Change subject: soc/amd/picasso: Avoid NULL pointer dereference ......................................................................
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 john.zhao@intel.com Change-Id: I6214fb83bccb19fe4edad65ce6b862815b8dcec6 Reviewed-on: https://review.coreboot.org/c/coreboot/+/42837 Reviewed-by: Aaron Durbin adurbin@chromium.org Tested-by: build bot (Jenkins) no-reply@coreboot.org --- M src/soc/amd/picasso/root_complex.c 1 file changed, 6 insertions(+), 6 deletions(-)
Approvals: build bot (Jenkins): Verified Aaron Durbin: Looks good to me, approved
diff --git a/src/soc/amd/picasso/root_complex.c b/src/soc/amd/picasso/root_complex.c index 036ff00..1c06928 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 <acpi/acpigen.h> +#include <assert.h> #include <cbmem.h> #include <console/console.h> #include <cpu/amd/msr.h> @@ -134,14 +135,13 @@ 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);