]> git-server-git.apps.pok.os.sepia.ceph.com Git - xfsprogs-dev.git/commitdiff
misc: fix a few memory leaks
authorDarrick J. Wong <djwong@kernel.org>
Mon, 2 Mar 2026 19:54:14 +0000 (11:54 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 10 Mar 2026 03:34:29 +0000 (20:34 -0700)
valgrind caught these while I was trying to debug xfs/841 regression so
fix them.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
mkfs/proto.c
mkfs/xfs_mkfs.c

index 1a7b3586581278ca24395176d559f7fa1e5dd8de..3241a066f72951b98caaa6821c22aaa5165eee16 100644 (file)
@@ -1412,19 +1412,19 @@ handle_hardlink(
        struct xfs_trans        *tp;
        struct xfs_parent_args  *ppargs = NULL;
 
-       tp = getres(mp, 0);
-       ppargs = newpptr(mp);
-       dst_ino = get_hardlink_dst_inode(file_stat.st_ino);
-
        /*
         * We didn't find the hardlink inode, this means it's the first time
         * we see it, report error so create_nondir_inode() can continue handling the
         * inode as a regular file type, and later save the source inode in our
         * buffer for future consumption.
         */
+       dst_ino = get_hardlink_dst_inode(file_stat.st_ino);
        if (dst_ino == 0)
                return false;
 
+       tp = getres(mp, 0);
+       ppargs = newpptr(mp);
+
        error = -libxfs_iget(mp, NULL, dst_ino, 0, &ip);
        if (error)
                fail(_("failed to get inode"), error);
@@ -1546,12 +1546,7 @@ create_nondir_inode(
                close(fd);
                return;
        }
-       /*
-        * If instead we have an error it means the hardlink was not registered,
-        * so we proceed to treat it like a regular file, and save it to our
-        * tracker later.
-        */
-       tp = getres(mp, 0);
+
        /*
         * In case of symlinks, we need to handle things a little differently.
         * We need to read out our link target and act accordingly.
@@ -1563,6 +1558,8 @@ create_nondir_inode(
                if (link_len >= PATH_MAX)
                        fail(_("symlink target too long"), ENAMETOOLONG);
                tp = getres(mp, XFS_B_TO_FSB(mp, link_len));
+       } else {
+               tp = getres(mp, 0);
        }
        ppargs = newpptr(mp);
 
index a7a6fde93277970134282167387d707e1c9c6d1d..ece20905b283131dad06588d6560e81c021a7cad 100644 (file)
@@ -5824,6 +5824,7 @@ set_autofsck(
        }
 
        libxfs_irele(args.dp);
+       free(p);
 }
 
 /* Write the realtime superblock */