vboot: fix vb2_gbb_read_recovery_key to save into int

Return value of vb2_gbb_read_recovery_key should be saved into an
integer, not into vboot1-style VbError_t.

BUG=b:124141368, chromium:954774
TEST=make clean && make runtests
BRANCH=none

Change-Id: Icbe622c9958d3f303da0faf7b52b0ce52c2b16a5
Signed-off-by: Joel Kitching <kitching@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1648093
Tested-by: Joel Kitching <kitching@chromium.org>
Auto-Submit: Joel Kitching <kitching@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Commit-Queue: Julius Werner <jwerner@chromium.org>
This commit is contained in:
Joel Kitching 2019-06-09 12:44:32 +08:00 committed by Commit Bot
parent 4c1a6f4872
commit b4b4507d61
2 changed files with 22 additions and 20 deletions

View File

@ -471,11 +471,13 @@ VbError_t VbVerifyMemoryBootImage(
int dev_switch;
uint32_t allow_fastboot_full_cap = 0;
struct vb2_workbuf wb;
VbError_t retval;
int rv;
/* Allocate work buffer */
vb2_workbuf_from_ctx(ctx, &wb);
VbError_t retval = vb2_kernel_setup(ctx, shared, kparams);
retval = vb2_kernel_setup(ctx, shared, kparams);
if (retval)
goto fail;
@ -510,10 +512,10 @@ VbError_t VbVerifyMemoryBootImage(
hash_only = 1;
} else {
/* Get recovery key. */
retval = vb2_gbb_read_recovery_key(ctx, &kernel_subkey,
NULL, &wb);
if (VBERROR_SUCCESS != retval) {
VB2_DEBUG("Gbb Read Recovery key failed.\n");
rv = vb2_gbb_read_recovery_key(ctx, &kernel_subkey, NULL, &wb);
if (VB2_SUCCESS != rv) {
VB2_DEBUG("GBB read recovery key failed.\n");
retval = VBERROR_INVALID_GBB;
goto fail;
}
}
@ -524,7 +526,7 @@ VbError_t VbVerifyMemoryBootImage(
/* Verify the key block. */
key_block = (VbKeyBlockHeader *)kbuf;
struct vb2_keyblock *keyblock2 = (struct vb2_keyblock *)kbuf;
int rv;
rv = VB2_SUCCESS;
if (hash_only) {
rv = vb2_verify_keyblock_hash(keyblock2, image_size, &wb);
} else {

View File

@ -440,12 +440,11 @@ VbError_t LoadKernel(struct vb2_context *ctx, LoadKernelParams *params)
struct vb2_workbuf wb;
VbSharedDataHeader *shared = sd->vbsd;
VbSharedDataKernelCall *shcall = NULL;
struct vb2_packed_key *recovery_key = NULL;
int found_partitions = 0;
uint32_t lowest_version = LOWEST_TPM_VERSION;
VbError_t retval = VBERROR_UNKNOWN;
int recovery = VB2_RECOVERY_LK_UNSPECIFIED;
int rv;
vb2_workbuf_from_ctx(ctx, &wb);
@ -472,11 +471,12 @@ VbError_t LoadKernel(struct vb2_context *ctx, LoadKernelParams *params)
struct vb2_packed_key *kernel_subkey;
if (kBootRecovery == shcall->boot_mode) {
/* Use the recovery key to verify the kernel */
retval = vb2_gbb_read_recovery_key(ctx, &recovery_key,
NULL, &wb);
if (VBERROR_SUCCESS != retval)
rv = vb2_gbb_read_recovery_key(ctx, &kernel_subkey, NULL, &wb);
if (VB2_SUCCESS != rv) {
VB2_DEBUG("GBB read recovery key failed.\n");
retval = VBERROR_INVALID_GBB;
goto load_kernel_exit;
kernel_subkey = recovery_key;
}
} else {
/* Use the kernel subkey passed from firmware verification */
kernel_subkey = (struct vb2_packed_key *)&shared->kernel_subkey;
@ -552,14 +552,14 @@ VbError_t LoadKernel(struct vb2_context *ctx, LoadKernelParams *params)
lpflags |= VB2_LOAD_PARTITION_VBLOCK_ONLY;
}
int rv = vb2_load_partition(ctx,
stream,
kernel_subkey,
lpflags,
params,
shared->kernel_version_tpm,
shpart,
&wb);
rv = vb2_load_partition(ctx,
stream,
kernel_subkey,
lpflags,
params,
shared->kernel_version_tpm,
shpart,
&wb);
VbExStreamClose(stream);
if (rv != VB2_SUCCESS) {