summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Schmidt <snst@meek.de>2020-12-05 13:44:17 +0100
committerJerome Forissier <jerome@forissier.org>2021-01-05 15:43:59 +0100
commit3c53421141e04a7a6d49af5432b889c2bbaa43b8 (patch)
treea673502e0fc4a1389161aeef7c64aac82bc0cb8c
parent3f286c3b9c107cd0f765967b3d9c1cc3c563477d (diff)
core: rpmb: return TEE_ERROR_STORAGE_NO_SPACE if no space left
So far the error TEE_ERROR_OUT_OF_MEMORY was returned if no free memory could be allocated in the RPMB to store new data. According to TEE Internal Core API Specification the error TEE_ERROR_STORAGE_NO_SPACE shall be returned if insufficient space is available to create the persistent object. Signed-off-by: Stefan Schmidt <snst@meek.de> Reviewed-by: Jerome Forissier <jerome@forissier.org> Acked-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
-rw-r--r--core/tee/tee_rpmb_fs.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/core/tee/tee_rpmb_fs.c b/core/tee/tee_rpmb_fs.c
index 84d1f2f2..c07695d3 100644
--- a/core/tee/tee_rpmb_fs.c
+++ b/core/tee/tee_rpmb_fs.c
@@ -2437,8 +2437,13 @@ static TEE_Result rpmb_fs_write_primitive(struct rpmb_file_handle *fh,
DMSG("Need to re-allocate");
newsize = MAX(end, fh->fat_entry.data_size);
mm = tee_mm_alloc(&p, newsize);
+ if (!mm) {
+ DMSG("RPMB: No space left");
+ res = TEE_ERROR_STORAGE_NO_SPACE;
+ goto out;
+ }
newbuf = calloc(1, newsize);
- if (!mm || !newbuf) {
+ if (!newbuf) {
res = TEE_ERROR_OUT_OF_MEMORY;
goto out;
}