diff options
author | Yu-Ping Wu <yupingso@chromium.org> | 2019-11-26 11:04:07 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-01-03 20:14:29 +0000 |
commit | c77bdcd04a07b8fbb5815d7a1676bae7ee14793f (patch) | |
tree | 95ac97c717e879ef586afc6e08711e7737bfeb8e | |
parent | dfeab24959351002ea7b2d57bc06d39ae31918df (diff) | |
download | vboot-c77bdcd04a07b8fbb5815d7a1676bae7ee14793f.tar.gz |
vboot: Add const modifier to vb2api_relocate argument
BRANCH=none
BUG=none
TEST=emerge-nami vboot_reference coreboot
Change-Id: I83a82a8b931c074e83ced8ea41c215d70825881e
Signed-off-by: Yu-Ping Wu <yupingso@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1935272
Reviewed-by: Joel Kitching <kitching@chromium.org>
(cherry picked from commit 16e6fe39f94e802cadcd67ae0ac612aa6ec1ee7f)
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1986987
Reviewed-by: Shelley Chen <shchen@chromium.org>
Commit-Queue: Shelley Chen <shchen@chromium.org>
Tested-by: Shelley Chen <shchen@chromium.org>
-rw-r--r-- | firmware/2lib/2context.c | 27 | ||||
-rw-r--r-- | firmware/2lib/include/2api.h | 4 |
2 files changed, 16 insertions, 15 deletions
diff --git a/firmware/2lib/2context.c b/firmware/2lib/2context.c index 1ee5a3cc..2fa017d9 100644 --- a/firmware/2lib/2context.c +++ b/firmware/2lib/2context.c @@ -52,40 +52,41 @@ vb2_error_t vb2api_init(void *workbuf, uint32_t size, #pragma GCC diagnostic push /* Don't warn for the version_minor check even if the checked version is 0. */ #pragma GCC diagnostic ignored "-Wtype-limits" -vb2_error_t vb2api_relocate(void *new_workbuf, void *cur_workbuf, uint32_t size, - struct vb2_context **ctxptr) +vb2_error_t vb2api_relocate(void *new_workbuf, const void *cur_workbuf, + uint32_t size, struct vb2_context **ctxptr) { - struct vb2_shared_data *sd = cur_workbuf; + const struct vb2_shared_data *cur_sd = cur_workbuf; + struct vb2_shared_data *new_sd; if (!vb2_aligned(new_workbuf, VB2_WORKBUF_ALIGN)) return VB2_ERROR_WORKBUF_ALIGN; /* Check magic and version. */ - if (sd->magic != VB2_SHARED_DATA_MAGIC) + if (cur_sd->magic != VB2_SHARED_DATA_MAGIC) return VB2_ERROR_SHARED_DATA_MAGIC; - if (sd->struct_version_major != VB2_SHARED_DATA_VERSION_MAJOR || - sd->struct_version_minor < VB2_SHARED_DATA_VERSION_MINOR) + if (cur_sd->struct_version_major != VB2_SHARED_DATA_VERSION_MAJOR || + cur_sd->struct_version_minor < VB2_SHARED_DATA_VERSION_MINOR) return VB2_ERROR_SHARED_DATA_VERSION; /* Check workbuf integrity. */ - if (sd->workbuf_used < vb2_wb_round_up(sizeof(*sd))) + if (cur_sd->workbuf_used < vb2_wb_round_up(sizeof(*cur_sd))) return VB2_ERROR_WORKBUF_INVALID; - if (sd->workbuf_size < sd->workbuf_used) + if (cur_sd->workbuf_size < cur_sd->workbuf_used) return VB2_ERROR_WORKBUF_INVALID; - if (sd->workbuf_used > size) + if (cur_sd->workbuf_used > size) return VB2_ERROR_WORKBUF_SMALL; /* Relocate if necessary. */ if (cur_workbuf != new_workbuf) - memmove(new_workbuf, cur_workbuf, sd->workbuf_used); + memmove(new_workbuf, cur_workbuf, cur_sd->workbuf_used); /* Set the new size, and return the context pointer. */ - sd = new_workbuf; - sd->workbuf_size = size; - *ctxptr = &sd->ctx; + new_sd = new_workbuf; + new_sd->workbuf_size = size; + *ctxptr = &new_sd->ctx; return VB2_SUCCESS; } diff --git a/firmware/2lib/include/2api.h b/firmware/2lib/include/2api.h index d178268a..d47cc1a9 100644 --- a/firmware/2lib/include/2api.h +++ b/firmware/2lib/include/2api.h @@ -472,8 +472,8 @@ vb2_error_t vb2api_reinit(void *workbuf, struct vb2_context **ctxptr); * @param ctxptr Pointer to a context pointer to be filled in * @return VB2_SUCCESS, or non-zero error code. */ -vb2_error_t vb2api_relocate(void *new_workbuf, void *cur_workbuf, uint32_t size, - struct vb2_context **ctxptr); +vb2_error_t vb2api_relocate(void *new_workbuf, const void *cur_workbuf, + uint32_t size, struct vb2_context **ctxptr); /** * Check the validity of firmware secure storage context. |