From ad3330ff29ec20a3b94b48c2f992728a3edbf166 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Wed, 4 Jan 2023 13:10:59 +0100 Subject: [PATCH] libmount: (idmap) fix leak and doble free [coverity scan] Signed-off-by: Karel Zak --- libmount/src/hook_idmap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libmount/src/hook_idmap.c b/libmount/src/hook_idmap.c index da4e1e65ff..3001e40624 100644 --- a/libmount/src/hook_idmap.c +++ b/libmount/src/hook_idmap.c @@ -377,7 +377,7 @@ static int hook_prepare_options( buf = strdup(value); if (!buf) - return -ENOMEM; + goto err; /* * This is an explicit ID-mapping list of the form: @@ -440,8 +440,6 @@ static int hook_prepare_options( goto err; done: - free(buf); - /* define post-mount hook to enter the namespace */ DBG(HOOK, ul_debugobj(hs, " wanted new user namespace")); rc = mnt_context_append_hook(cxt, hs, @@ -449,6 +447,8 @@ done: hd, hook_mount_post); if (rc < 0) goto err; + + free(buf); return 0; err: -- 2.47.3