Skip to content

Commit 095af29

Browse files
Boerje Sewingjforissier
authored andcommitted
secure_storage: fix obj_id memory leak
Call TEE_Free on obj_id pointer after the object id is copied into the object. Signed-off-by: Boerje Sewing <[email protected]> Reviewed-by: Etienne Carriere <[email protected]> Reviewed-by: Jerome Forissier <[email protected]>
1 parent c7df388 commit 095af29

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

secure_storage/ta/secure_storage_ta.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,10 @@ static TEE_Result create_raw_object(uint32_t param_types, TEE_Param params[4])
105105

106106
data_sz = params[1].memref.size;
107107
data = TEE_Malloc(data_sz, 0);
108-
if (!data)
108+
if (!data) {
109+
TEE_Free(obj_id);
109110
return TEE_ERROR_OUT_OF_MEMORY;
111+
}
110112
TEE_MemMove(data, params[1].memref.buffer, data_sz);
111113

112114
/*
@@ -173,8 +175,10 @@ static TEE_Result read_raw_object(uint32_t param_types, TEE_Param params[4])
173175

174176
data_sz = params[1].memref.size;
175177
data = TEE_Malloc(data_sz, 0);
176-
if (!data)
178+
if (!data) {
179+
TEE_Free(obj_id);
177180
return TEE_ERROR_OUT_OF_MEMORY;
181+
}
178182

179183
/*
180184
* Check the object exist and can be dumped into output buffer

0 commit comments

Comments
 (0)