Skip to content

Commit

Permalink
core: fix OOM handling in tee_svc_storage_read_head()
Browse files Browse the repository at this point in the history
Fixes out of memory handling error in tee_svc_storage_read_head(). Prior
to this all errors from fops->read() was reported as
TEE_ERROR_CORRUPT_OBJECT leading to removal of the object even when the
real problem was temporary memory shortage. This patch reports
TEE_ERROR_OUT_OF_MEMORY from fops->read() correctly while translating
all other errors to TEE_ERROR_CORRUPT_OBJECT.

Reviewed-by: Etienne Carriere <[email protected]>
Signed-off-by: Jens Wiklander <[email protected]>
  • Loading branch information
jenswi-linaro committed May 14, 2018
1 parent bce296d commit d45029a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions core/tee/tee_svc_storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +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 || bytes != head.attr_size) {
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 d45029a

Please sign in to comment.