From: Karel Zak Date: Wed, 4 Jan 2023 12:10:59 +0000 (+0100) Subject: libmount: (idmap) fix leak and doble free [coverity scan] X-Git-Tag: v2.39-rc1~210 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ad3330ff29ec20a3b94b48c2f992728a3edbf166;p=thirdparty%2Futil-linux.git libmount: (idmap) fix leak and doble free [coverity scan] Signed-off-by: Karel Zak --- 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: