summaryrefslogtreecommitdiffstats
path: root/src/soc
diff options
context:
space:
mode:
authorJohn Zhao <john.zhao@intel.com>2020-06-26 10:00:02 -0700
committerAaron Durbin <adurbin@chromium.org>2020-07-10 17:33:39 +0000
commitf6f1f734ee1b6322ebf3913743d5c526be65dc42 (patch)
tree2ab3194dbc31cbc4ed5d170a83ab2dab56b4bd92 /src/soc
parent7b1cb0d603ee38470d5571d564c6b4fed5348977 (diff)
downloadcoreboot-f6f1f734ee1b6322ebf3913743d5c526be65dc42.tar.gz
coreboot-f6f1f734ee1b6322ebf3913743d5c526be65dc42.tar.bz2
coreboot-f6f1f734ee1b6322ebf3913743d5c526be65dc42.zip
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>
Diffstat (limited to 'src/soc')
-rw-r--r--src/soc/amd/picasso/root_complex.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/soc/amd/picasso/root_complex.c b/src/soc/amd/picasso/root_complex.c
index 036ff00ccbab..1c069282af0b 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 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);