aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorChristopher Tam <godtamit@google.com>2019-04-10 17:46:18 -0700
committerJérôme Forissier <jerome.forissier@linaro.org>2019-04-15 21:37:10 +0200
commit13e224aa32b2a6d928b6b2b5837753e1e966749c (patch)
tree3fb15d40860d8f3b46780c21135e2e8b7dfcd5c7 /core
parentbccaa847d21b19d38988d2ab85b77ac5109608f0 (diff)
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 <godtamit@google.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Tested-by: Jerome Forissier <jerome.forissier@linaro.org> (QEMU, GP)
Diffstat (limited to 'core')
-rw-r--r--core/tee/tee_svc_storage.c21
1 files 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: