summaryrefslogtreecommitdiff
path: root/firmware/lib/vboot_kernel.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/lib/vboot_kernel.c')
-rw-r--r--firmware/lib/vboot_kernel.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/firmware/lib/vboot_kernel.c b/firmware/lib/vboot_kernel.c
index aa1e41e3..72cd2cc1 100644
--- a/firmware/lib/vboot_kernel.c
+++ b/firmware/lib/vboot_kernel.c
@@ -10,6 +10,8 @@
#include "cgptlib.h"
#include "cgptlib_internal.h"
+#include "region.h"
+#include "gbb_access.h"
#include "gbb_header.h"
#include "load_kernel_fw.h"
#include "utility.h"
@@ -159,15 +161,14 @@ fail:
return ret;
}
-VbError_t LoadKernel(LoadKernelParams *params)
+VbError_t LoadKernel(LoadKernelParams *params, VbCommonParams *cparams)
{
VbSharedDataHeader *shared =
(VbSharedDataHeader *)params->shared_data_blob;
VbSharedDataKernelCall *shcall = NULL;
VbNvContext* vnc = params->nv_context;
- GoogleBinaryBlockHeader* gbb =
- (GoogleBinaryBlockHeader *)params->gbb_data;
- VbPublicKey* kernel_subkey;
+ VbPublicKey* kernel_subkey = NULL;
+ int free_kernel_subkey = 0;
GptData gpt;
uint64_t part_start, part_size;
uint64_t blba;
@@ -233,8 +234,10 @@ VbError_t LoadKernel(LoadKernelParams *params)
if (kBootRecovery == boot_mode) {
/* Use the recovery key to verify the kernel */
- kernel_subkey = (VbPublicKey*)
- ((uint8_t*)gbb + gbb->recovery_key_offset);
+ retval = VbGbbReadRecoveryKey(cparams, &kernel_subkey);
+ if (VBERROR_SUCCESS != retval)
+ goto LoadKernelExit;
+ free_kernel_subkey = 1;
} else {
/* Use the kernel subkey passed from LoadFirmware(). */
kernel_subkey = &shared->kernel_subkey;
@@ -632,5 +635,8 @@ VbError_t LoadKernel(LoadKernelParams *params)
/* Store how much shared data we used, if any */
params->shared_data_size = shared->data_used;
+ if (free_kernel_subkey)
+ VbExFree(kernel_subkey);
+
return retval;
}