Skip to content

Commit

Permalink
libckteec: fix memory allocation leakage on template serialization
Browse files Browse the repository at this point in the history
Fix memory allocation leakage with a call to release_serial_object()
to release obj2 before serialize_indirect_attribute() returns.

Link: OP-TEE#387
Fixes: e88c264 ("libckteec: helper function to serialize a attribute template")
Signed-off-by: Hoyong Jin <hoyong2007@naver.com>
Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com>
  • Loading branch information
hoyong2007 committed Sep 19, 2024
1 parent a5b1ffc commit dc3dc43
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions libckteec/src/serialize_ck.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,19 @@ static CK_RV serialize_indirect_attribute(struct serializer *obj,
*/
rv = serialize_32b(obj, attribute->type);
if (rv)
return rv;
goto out;

rv = serialize_32b(obj, obj2.size);
if (rv)
return rv;
goto out;

rv = serialize_buffer(obj, obj2.buffer, obj2.size);
if (rv)
return rv;
goto out;

obj->item_count++;
out:
release_serial_object(&obj2);

return rv;
}
Expand Down

0 comments on commit dc3dc43

Please sign in to comment.