From 13e224aa32b2a6d928b6b2b5837753e1e966749c Mon Sep 17 00:00:00 2001 From: Christopher Tam Date: Wed, 10 Apr 2019 17:46:18 -0700 Subject: core: storage: set data length after truncation After truncating a persistent object, update dataSize in the corresponding TEE_ObjectInfo structure. Signed-off-by: Christopher Tam Reviewed-by: Jens Wiklander Tested-by: Jerome Forissier (QEMU, GP) --- core/tee/tee_svc_storage.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/core/tee/tee_svc_storage.c b/core/tee/tee_svc_storage.c index 7bee121a..b8ea4feb 100644 --- a/core/tee/tee_svc_storage.c +++ b/core/tee/tee_svc_storage.c @@ -925,16 +925,17 @@ TEE_Result syscall_storage_obj_trunc(unsigned long obj, size_t len) off = sizeof(struct tee_svc_storage_head) + attr_size; res = o->pobj->fops->truncate(o->fh, len + off); - if (res != TEE_SUCCESS) { - if (res == TEE_ERROR_CORRUPT_OBJECT) { - EMSG("Object corrupt"); - res = tee_svc_storage_remove_corrupt_obj(sess, o); - if (res != TEE_SUCCESS) - goto exit; - res = TEE_ERROR_CORRUPT_OBJECT; - goto exit; - } else - res = TEE_ERROR_GENERIC; + switch (res) { + case TEE_SUCCESS: + o->info.dataSize = len; + break; + case TEE_ERROR_CORRUPT_OBJECT: + EMSG("Object corruption"); + (void)tee_svc_storage_remove_corrupt_obj(sess, o); + break; + default: + res = TEE_ERROR_GENERIC; + break; } exit: -- cgit v1.2.3