From 4f660d814210f2582bed9e9c830c0f179f722d03 Mon Sep 17 00:00:00 2001 From: Jakub Wlostowski Date: Tue, 17 Dec 2024 16:26:38 +0100 Subject: [PATCH] Fix TEE_CreatePersistentObject failure Running UPDATE_API_BENCHMARKS from key-manager multiple times resulted in crashes and tests fails. To fix this we need to check whether a persistent object already exists, if it does we need to free it and only then create a new one. Change-Id: I9d6de16194e034bc1d65d0e95b193cf9a2a717cb --- ssflib/src/ssf_storage.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ssflib/src/ssf_storage.cpp b/ssflib/src/ssf_storage.cpp index 01d4cce..24a2915 100644 --- a/ssflib/src/ssf_storage.cpp +++ b/ssflib/src/ssf_storage.cpp @@ -2025,9 +2025,12 @@ TEE_Result TEE_CreatePersistentObject(uint32_t storageID, const void* objectID, FREE_PO(po); return TEE_ERROR_ACCESS_CONFLICT; } - if (!object) { - FREE_PO(po); - return TEE_SUCCESS; + + free_po(po); + rc = allocate_persistent_object(&po, storageID, objectID, + objectIDLen, flags); + if (rc) { + return rc; } } rc = create_po(po, tr_obj, initialData, initialDataLen); -- 2.34.1