From 2b8b43b3db3ea3968df219d9e6b2b33ee1beb8fc Mon Sep 17 00:00:00 2001 From: Milan Broz Date: Thu, 7 Feb 2019 17:37:16 +0100 Subject: [PATCH] Fix file descriptor leak in error path. --- lib/utils_wipe.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/utils_wipe.c b/lib/utils_wipe.c index 3ce3acb5..caf7890e 100644 --- a/lib/utils_wipe.c +++ b/lib/utils_wipe.c @@ -166,10 +166,12 @@ int crypt_wipe_device(struct crypt_device *cd, else { r = device_size(device, &dev_size); if (r) - return r; + goto out; - if (dev_size <= offset) - return -EINVAL; + if (dev_size <= offset) { + r = -EINVAL; + goto out; + } } r = posix_memalign((void **)&sf, alignment, wipe_block_size);