From 77546604092dd6eb37b6b7cf6b4358fef4e63f5c Mon Sep 17 00:00:00 2001 From: Milan Broz Date: Mon, 17 Jul 2023 15:31:49 +0200 Subject: [PATCH] Fix leak of volume key in activation code error path. --- lib/setup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/setup.c b/lib/setup.c index 77347a44..fdcb4e51 100644 --- a/lib/setup.c +++ b/lib/setup.c @@ -4586,7 +4586,7 @@ static int _open_and_activate(struct crypt_device *cd, { bool use_keyring; int r; - struct volume_key *p_crypt, *p_opal, *crypt_key = NULL, *opal_key = NULL, *vk = NULL; + struct volume_key *p_crypt = NULL, *p_opal = NULL, *crypt_key = NULL, *opal_key = NULL, *vk = NULL; r = LUKS2_keyslot_open(cd, keyslot, (flags & CRYPT_ACTIVATE_ALLOW_UNBOUND_KEY) ? @@ -4601,7 +4601,7 @@ static int _open_and_activate(struct crypt_device *cd, vk, &crypt_key, &opal_key); if (r < 0) - return r; + goto out; p_crypt = crypt_key; p_opal = opal_key ?: vk;