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>
This commit is contained in:
parent
d2894f690a
commit
51ffa7e810
|
@ -163,11 +163,12 @@ static void vboot_migrate_cbmem(int unused)
|
||||||
size_t cbmem_size = wd_preram->buffer_offset + wd_preram->buffer_size;
|
size_t cbmem_size = wd_preram->buffer_offset + wd_preram->buffer_size;
|
||||||
struct vboot_working_data *wd_cbmem =
|
struct vboot_working_data *wd_cbmem =
|
||||||
cbmem_add(CBMEM_ID_VBOOT_WORKBUF, cbmem_size);
|
cbmem_add(CBMEM_ID_VBOOT_WORKBUF, cbmem_size);
|
||||||
|
assert(wd_cbmem != NULL);
|
||||||
|
|
||||||
printk(BIOS_DEBUG,
|
printk(BIOS_DEBUG,
|
||||||
"VBOOT: copying vboot_working_data (%zu bytes) to CBMEM...\n",
|
"VBOOT: copying vboot_working_data (%zu bytes) to CBMEM...\n",
|
||||||
cbmem_size);
|
cbmem_size);
|
||||||
memcpy(wd_cbmem, wd_preram, cbmem_size);
|
memcpy(wd_cbmem, wd_preram, cbmem_size);
|
||||||
assert(wd_cbmem != NULL);
|
|
||||||
}
|
}
|
||||||
ROMSTAGE_CBMEM_INIT_HOOK(vboot_migrate_cbmem)
|
ROMSTAGE_CBMEM_INIT_HOOK(vboot_migrate_cbmem)
|
||||||
#elif CONFIG(VBOOT_STARTS_IN_ROMSTAGE)
|
#elif CONFIG(VBOOT_STARTS_IN_ROMSTAGE)
|
||||||
|
|
Loading…
Reference in New Issue