]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: (idmap) fix leak and doble free [coverity scan]
authorKarel Zak <kzak@redhat.com>
Wed, 4 Jan 2023 12:10:59 +0000 (13:10 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 4 Jan 2023 12:10:59 +0000 (13:10 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/hook_idmap.c

index da4e1e65ff3d3262b3fd0d8031d46d8c9f8674f7..3001e406249f18c4882fc2599b0ef85ab25518a7 100644 (file)
@@ -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: