]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
mac_legacy_kmgmt.c: Avoid possible memory leak on error
authorTomas Mraz <tomas@openssl.org>
Tue, 21 Jan 2025 13:38:23 +0000 (14:38 +0100)
committerTomas Mraz <tomas@openssl.org>
Thu, 23 Jan 2025 11:09:35 +0000 (12:09 +0100)
Use mac_gen_cleanup() instead of just freeing the gctx.
Fixes Coverity 1638702

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/26500)

(cherry picked from commit 2455ef2112997d6a366623a209f1d0090ed2d847)

providers/implementations/keymgmt/mac_legacy_kmgmt.c

index f952ebb2277ab9dcf421970d32a6f3089e2d401f..0bb187c105d99126a7cace9e3dbe3da0f324a739 100644 (file)
@@ -393,7 +393,7 @@ static void *mac_gen_init(void *provctx, int selection,
     struct mac_gen_ctx *gctx = mac_gen_init_common(provctx, selection);
 
     if (gctx != NULL && !mac_gen_set_params(gctx, params)) {
-        OPENSSL_free(gctx);
+        mac_gen_cleanup(gctx);
         gctx = NULL;
     }
     return gctx;
@@ -405,7 +405,7 @@ static void *cmac_gen_init(void *provctx, int selection,
     struct mac_gen_ctx *gctx = mac_gen_init_common(provctx, selection);
 
     if (gctx != NULL && !cmac_gen_set_params(gctx, params)) {
-        OPENSSL_free(gctx);
+        mac_gen_cleanup(gctx);
         gctx = NULL;
     }
     return gctx;