From: Gao Xiang <xiang@kernel.org>
To: linux-erofs@lists.ozlabs.org
Subject: [PATCH] erofs-utils: fix reference leak in erofs_mkfs_build_tree_from_path()
Date: Fri, 20 Oct 2023 06:43:28 +0800 [thread overview]
Message-ID: <20231019224328.26015-1-xiang@kernel.org> (raw)
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
reply other threads:[~2023-10-19 22:44 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231019224328.26015-1-xiang@kernel.org \
--to=xiang@kernel.org \
--cc=linux-erofs@lists.ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox