All error handling paths, except but this one, branch to the 'bad' label in
the error handling path.

If not done, there is a memory leak and some sensitive data may be kept
around.

So, fix this error path and also do the needed clean-up.

Fixes: e7f57d2c47e2 ("dm-inlinecrypt: add target for inline block device 
encryption")
Signed-off-by: Christophe JAILLET <[email protected]>
---
Compile tested only
---
 drivers/md/dm-inlinecrypt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/md/dm-inlinecrypt.c b/drivers/md/dm-inlinecrypt.c
index be1b4aa8f28b..bb4ded4757d1 100644
--- a/drivers/md/dm-inlinecrypt.c
+++ b/drivers/md/dm-inlinecrypt.c
@@ -347,7 +347,8 @@ static int inlinecrypt_ctr(struct dm_target *ti, unsigned 
int argc, char **argv)
        err = get_key_size(&argv[1]);
        if (err < 0) {
                ti->error = "Cannot parse key size";
-               return -EINVAL;
+               err = -EINVAL;
+               goto bad;
        }
        ctx->key_size = err;
 
-- 
2.54.0


Reply via email to