From 55a4d839310ce46aca79a12015ab8e1da9f110e5 Mon Sep 17 00:00:00 2001 From: Georges Savoundararadj Date: Wed, 4 Sep 2024 08:21:18 +0000 Subject: [PATCH] ta: pkcs11: fix memory leak On update_persistent_object_attributes failure, head_new (stored in obj->attributes) is not freed, causing a memory leak. Reported-by: Christian Zoia Closes: https://github.com/OP-TEE/optee_os/issues/7023 Fixes: 6959626e1621 ("ta: pkcs11: preserve object when set attribute fails") Signed-off-by: Georges Savoundararadj Reviewed-by: Jerome Forissier Reviewed-by: Etienne Carriere --- ta/pkcs11/src/object.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ta/pkcs11/src/object.c b/ta/pkcs11/src/object.c index bbd2b682288..c9a95e1b274 100644 --- a/ta/pkcs11/src/object.c +++ b/ta/pkcs11/src/object.c @@ -1094,6 +1094,7 @@ enum pkcs11_rc entry_set_attribute_value(struct pkcs11_client *client, if (get_bool(obj->attributes, PKCS11_CKA_TOKEN)) { rc = update_persistent_object_attributes(obj); if (rc) { + TEE_Free(obj->attributes); obj->attributes = head_old; goto out; }