Skip to content

Commit

Permalink
[review] core: fix OOM handling in tee_svc_storage_read_head()
Browse files Browse the repository at this point in the history
Signed-off-by: Jens Wiklander <[email protected]>
  • Loading branch information
jenswi-linaro committed May 14, 2018
1 parent 8646d6d commit 7754734
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions core/tee/tee_svc_storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit 7754734

Please sign in to comment.