soc/intel/braswell: Prevent NULL pointer dereference

Exit early if the chipset power state info isn't in CBMEM. Return -1 in
order to ensure the one caller of this function exits early as well.

Found-by: Coverity CID 1442304
Change-Id: Ifa42ba3024d3144de486d90ed7752820482549bf
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/49359
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Lance Zhao
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Angel Pons 2021-01-12 17:13:05 +01:00 committed by Patrick Georgi
parent 77a7520385
commit 06e6983002
1 changed files with 3 additions and 0 deletions

View File

@ -125,6 +125,9 @@ int soc_fill_acpi_wake(uint32_t *pm1, uint32_t **gpe0)
struct chipset_power_state *ps = cbmem_find(CBMEM_ID_POWER_STATE);
static uint32_t gpe0_sts;
if (!ps)
return -1;
*pm1 = ps->pm1_sts & ps->pm1_en;
gpe0_sts = ps->gpe0_sts & ps->gpe0_en;