From d45029aa350f7b9a440f4e154efde103d8a2c1db Mon Sep 17 00:00:00 2001 From: Jens Wiklander Date: Mon, 14 May 2018 10:43:13 +0200 Subject: [PATCH] core: fix OOM handling in tee_svc_storage_read_head() 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 Signed-off-by: Jens Wiklander --- core/tee/tee_svc_storage.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/tee/tee_svc_storage.c b/core/tee/tee_svc_storage.c index 2f8a53a41ba..a412f15d94f 100644 --- a/core/tee/tee_svc_storage.c +++ b/core/tee/tee_svc_storage.c @@ -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);