diff --git a/core/tee/tee_svc_storage.c b/core/tee/tee_svc_storage.c index df2227a817b..a412f15d94f 100644 --- a/core/tee/tee_svc_storage.c +++ b/core/tee/tee_svc_storage.c @@ -214,8 +214,6 @@ static TEE_Result tee_svc_storage_read_head(struct tee_obj *o) bytes = sizeof(struct tee_svc_storage_head); res = fops->read(o->fh, 0, &head, &bytes); if (res != TEE_SUCCESS) { - if (res == TEE_ERROR_OUT_OF_MEMORY) - goto exit; if (res == TEE_ERROR_CORRUPT_OBJECT) EMSG("Head corrupt\n"); goto exit; @@ -242,13 +240,12 @@ static TEE_Result tee_svc_storage_read_head(struct tee_obj *o) bytes = head.attr_size; res = fops->read(o->fh, sizeof(struct tee_svc_storage_head), attr, &bytes); - if (res != TEE_SUCCESS) { - if (res == TEE_ERROR_OUT_OF_MEMORY) - goto exit; - if (bytes != head.attr_size) - res = TEE_ERROR_CORRUPT_OBJECT; + if (res == TEE_ERROR_OUT_OF_MEMORY) + goto exit; + if (res != TEE_SUCCESS || bytes != head.attr_size) + res = TEE_ERROR_CORRUPT_OBJECT; + if (res) goto exit; - } } res = tee_obj_attr_from_binary(o, attr, head.attr_size);