* [PATCH] erofs-utils: fix reference leak in erofs_mkfs_build_tree_from_path()
@ 2023-10-19 22:43 Gao Xiang
0 siblings, 0 replies; only message in thread
From: Gao Xiang @ 2023-10-19 22:43 UTC (permalink / raw)
To: linux-erofs
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@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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2023-10-19 22:44 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-19 22:43 [PATCH] erofs-utils: fix reference leak in erofs_mkfs_build_tree_from_path() Gao Xiang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.