summaryrefslogtreecommitdiff
path: root/lib/optee
diff options
context:
space:
mode:
authornathan-menhorn <41302213+nathan-menhorn@users.noreply.github.com>2018-07-17 09:08:30 -0600
committerNathan Menhorn <nathan.menhorn@xilinx.com>2018-08-23 14:44:18 -0600
commitb554e768297d205662fcd23da384d33a94a320c7 (patch)
treeb5bb9e048d09d8545baa248df79adf47e5a6083d /lib/optee
parent9ceda8b9076e1e09bcd4d2651632c7f7735248d7 (diff)
Fixed ARM-software/tf-issues#603
Updated optee_utils.c to fix ARM-software/tf-issues#603 related to the tee-validate-header bug. Minor updates to the header valid checking logic. It would never make sense to have less than 1 image to load so this is now checked. Changed OPTEE_MAX_IMAGE_NUM to OPTEE_MAX_NUM_IMAGES to clarify its definition. OPTEE_MAX_IMAGE_NUM sounds like an ID assigned to the last image to load. OPTEE_MAX_NUM_IMAGES sounds like the maximum number of images to load. Signed-off-by: Nathan Menhorn <nathan.menhorn@xilinx.com>
Diffstat (limited to 'lib/optee')
-rw-r--r--lib/optee/optee_utils.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/lib/optee/optee_utils.c b/lib/optee/optee_utils.c
index ecf7cc05..34d095b0 100644
--- a/lib/optee/optee_utils.c
+++ b/lib/optee/optee_utils.c
@@ -25,14 +25,15 @@ typedef struct optee_image {
#define OPTEE_PAGER_IMAGE_ID 0
#define OPTEE_PAGED_IMAGE_ID 1
-#define OPTEE_MAX_IMAGE_NUM 2
+
+#define OPTEE_MAX_NUM_IMAGES 2u
#define TEE_MAGIC_NUM_OPTEE 0x4554504f
/*
* magic: header magic number.
* version: OPTEE header version:
- * 1 - not supported
- * 2 - supported
+ * 1 - not supported
+ * 2 - supported
* arch: OPTEE os architecture type: 0 - AARCH32, 1 - AARCH64.
* flags: unused currently.
* nb_images: number of images.
@@ -53,14 +54,20 @@ typedef struct optee_header {
******************************************************************************/
static inline int tee_validate_header(optee_header_t *header)
{
+ int valid = 0;
+
if ((header->magic == TEE_MAGIC_NUM_OPTEE) &&
- (header->version == 2) &&
- (header->nb_images <= OPTEE_MAX_IMAGE_NUM)) {
- return 1;
+ (header->version == 2u) &&
+ (header->nb_images > 0u) &&
+ (header->nb_images <= OPTEE_MAX_NUM_IMAGES)) {
+ valid = 1;
}
- WARN("Not a known TEE, use default loading options.\n");
- return 0;
+ else {
+ WARN("Not a known TEE, use default loading options.\n");
+ }
+
+ return valid;
}
/*******************************************************************************