From bea6e0da74e5ff9dc488866f7ce446487f9f44ae Mon Sep 17 00:00:00 2001 From: Milan Broz Date: Thu, 4 Feb 2021 17:54:36 +0100 Subject: [PATCH] Fix an error path memory leak. --- src/cryptsetup.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cryptsetup.c b/src/cryptsetup.c index d0de25fa..bff46963 100644 --- a/src/cryptsetup.c +++ b/src/cryptsetup.c @@ -2393,8 +2393,10 @@ static int action_luksErase(void) /* Safety check */ max = crypt_keyslot_max(crypt_get_type(cd)); - if (max <= 0) - return -EINVAL; + if (max <= 0) { + r = -EINVAL; + goto out; + } for (i = 0; i < max; i++) { ki = crypt_keyslot_status(cd, i);