[PATCH] erofs-utils: fix reference leak in erofs_mkfs_build_tree_from_path()
Gao Xiang
xiang at kernel.org
Fri Oct 20 09:43:28 AEDT 2023
commit 8cbc205185a1 ("erofs-utils: mkfs: fix corrupted directories
with hardlinks") introduced a reference leak although it has no real
impact to users. Fix it now.
Signed-off-by: Gao Xiang <xiang at kernel.org>
---
lib/inode.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/lib/inode.c b/lib/inode.c
index 71af396..8409ccd 100644
--- a/lib/inode.c
+++ b/lib/inode.c
@@ -1271,13 +1271,18 @@ struct erofs_inode *erofs_mkfs_build_tree_from_path(const char *path)
if (S_ISDIR(inode->i_mode)) {
inode->next_dirwrite = dumpdir;
dumpdir = inode;
+ } else {
+ erofs_iput(inode);
}
} while (!list_empty(&dirs));
- for (; dumpdir; dumpdir = dumpdir->next_dirwrite) {
- erofs_write_dir_file(dumpdir);
- erofs_write_tail_end(dumpdir);
- dumpdir->bh->op = &erofs_write_inode_bhops;
+ while (dumpdir) {
+ inode = dumpdir;
+ erofs_write_dir_file(inode);
+ erofs_write_tail_end(inode);
+ inode->bh->op = &erofs_write_inode_bhops;
+ dumpdir = inode->next_dirwrite;
+ erofs_iput(inode);
}
return root;
}
--
2.30.2
More information about the Linux-erofs
mailing list