From 1de6dc68fcf422d052aa5220c24c5ba9163ed7c2 Mon Sep 17 00:00:00 2001 From: hoyong2007 Date: Fri, 13 Sep 2024 14:37:43 +0900 Subject: [PATCH] libckteec: fix memory allocation leakage on template serialization Fix memory allocation leakage with a call to release_serial_object() to release obj2 before serialize_indirect_attribute() returns. Link: https://github.com/OP-TEE/optee_client/issues/387 Fixes: e88c264ba358 ("libckteec: helper function to serialize a attribute template") Signed-off-by: Hoyong Jin --- libckteec/src/serialize_ck.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libckteec/src/serialize_ck.c b/libckteec/src/serialize_ck.c index 825677e2..c611e14c 100644 --- a/libckteec/src/serialize_ck.c +++ b/libckteec/src/serialize_ck.c @@ -95,18 +95,18 @@ 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;