From: Darrick J. Wong Date: Mon, 2 Mar 2026 19:54:14 +0000 (-0800) Subject: misc: fix a few memory leaks X-Git-Tag: v6.19.0~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=39c683bf82ae26ee48dd9e148cbfecbc9d9c295e;p=xfsprogs-dev.git misc: fix a few memory leaks valgrind caught these while I was trying to debug xfs/841 regression so fix them. Signed-off-by: "Darrick J. Wong" Reviewed-by: Christoph Hellwig --- diff --git a/mkfs/proto.c b/mkfs/proto.c index 1a7b3586..3241a066 100644 --- a/mkfs/proto.c +++ b/mkfs/proto.c @@ -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); diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index a7a6fde9..ece20905 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -5824,6 +5824,7 @@ set_autofsck( } libxfs_irele(args.dp); + free(p); } /* Write the realtime superblock */