Fix TEE_CreatePersistentObject failure 33/316733/2 tizen
authorJakub Wlostowski <j.wlostowski@samsung.com>
Tue, 17 Dec 2024 15:26:38 +0000 (16:26 +0100)
committerJakub Wlostowski <j.wlostowski@samsung.com>
Wed, 18 Dec 2024 10:19:47 +0000 (11:19 +0100)
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

index 01d4cce87ef12ecfc22b3b4f26aa0b5d46ad933f..24a2915d9f55beafe1406870e66206e2ad882b13 100644 (file)
@@ -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);