]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: remove possible leak in mnt_context_guess_srcpath_fstype() [coverity scan]
authorKarel Zak <kzak@redhat.com>
Wed, 12 Mar 2025 13:11:49 +0000 (14:11 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 12 Mar 2025 13:11:49 +0000 (14:11 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/context.c
libmount/src/hook_loopdev.c

index 3c1258882a85a158a2695c41a9aa0c2f518cbdda..0323cb23d3425528a9036742e283eeb2297412a6 100644 (file)
@@ -2023,8 +2023,11 @@ int mnt_context_guess_srcpath_fstype(struct libmnt_context *cxt, char **type)
                struct libmnt_opt *opt;
                const char *allowed;
 
-               if (!ol)
+               if (!ol) {
+                       free(*type);
+                       *type = NULL;
                        return -ENOMEM;
+               }
 
                opt = mnt_optlist_get_named(ol,
                                "X-mount.auto-fstypes", cxt->map_userspace);
index 4f831e0d888d248f3c49dd0fd9b96292dc260524..444d69d6f4c7b3fb80e922d9d4d78fb4e3ed1475 100644 (file)
@@ -458,6 +458,7 @@ static int is_loopdev_required(struct libmnt_context *cxt, struct libmnt_optlist
 
                rc = mnt_context_guess_srcpath_fstype(cxt, &autotype);
                if (rc) {
+                       free(autotype);;
                        DBG(CXT, ul_debugobj(cxt, "failed to guess regfile FS type [rc=%d]", rc));
                        return 0;
                }