diff options
author | Joel Kitching <kitching@google.com> | 2019-03-16 16:58:27 +0800 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2019-03-18 09:17:01 +0000 |
commit | 51ffa7e810ee243b24848a25c8f5193910886b32 (patch) | |
tree | a48e459f368032dd6e7b1a0dedcf3e413cc2321a /src | |
parent | d2894f690ade8bedefdf4b934f2d3f28c3086b1d (diff) | |
download | coreboot-51ffa7e810ee243b24848a25c8f5193910886b32.tar.xz |
vboot: move assert in vboot_migrate_cbmem
Fix a potential null pointer dereference when calling
memcpy. assert should be before the memcpy call,
and not after.
BUG=b:124141368, b:124192753
TEST=util/lint/checkpatch.pl -g origin/master..HEAD
TEST=util/abuild/abuild -B -e -y -c 50 -p none -x
TEST=make clean && make test-abuild
BRANCH=none
Change-Id: I5a2a99e906b9aa3bb33e1564d8d33a0aca7d06ac
Signed-off-by: Joel Kitching <kitching@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/31923
Reviewed-by: Furquan Shaikh <furquan@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/security/vboot/common.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/security/vboot/common.c b/src/security/vboot/common.c index 496ab782ab..47e1aa4f56 100644 --- a/src/security/vboot/common.c +++ b/src/security/vboot/common.c @@ -163,11 +163,12 @@ static void vboot_migrate_cbmem(int unused) size_t cbmem_size = wd_preram->buffer_offset + wd_preram->buffer_size; struct vboot_working_data *wd_cbmem = cbmem_add(CBMEM_ID_VBOOT_WORKBUF, cbmem_size); + assert(wd_cbmem != NULL); + printk(BIOS_DEBUG, "VBOOT: copying vboot_working_data (%zu bytes) to CBMEM...\n", cbmem_size); memcpy(wd_cbmem, wd_preram, cbmem_size); - assert(wd_cbmem != NULL); } ROMSTAGE_CBMEM_INIT_HOOK(vboot_migrate_cbmem) #elif CONFIG(VBOOT_STARTS_IN_ROMSTAGE) |