[PATCH 1/2] erofs-utils: derive i_srcpath for erofs_rebuild_mkdir()
Gao Xiang
hsiangkao at linux.alibaba.com
Mon Jun 24 21:59:22 AEST 2024
Also add missing erofs_iput() on errors.
Signed-off-by: Gao Xiang <hsiangkao at linux.alibaba.com>
---
lib/rebuild.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/lib/rebuild.c b/lib/rebuild.c
index 9c1e8f8..8b186eb 100644
--- a/lib/rebuild.c
+++ b/lib/rebuild.c
@@ -35,6 +35,11 @@ static struct erofs_dentry *erofs_rebuild_mkdir(struct erofs_inode *dir,
if (IS_ERR(inode))
return ERR_CAST(inode);
+ if (asprintf(&inode->i_srcpath, "%s/%s",
+ dir->i_srcpath ? : "", s) < 0) {
+ erofs_iput(inode);
+ return ERR_PTR(-ENOMEM);
+ }
inode->i_mode = S_IFDIR | 0755;
inode->i_parent = dir;
inode->i_uid = getuid();
@@ -44,7 +49,9 @@ static struct erofs_dentry *erofs_rebuild_mkdir(struct erofs_inode *dir,
erofs_init_empty_dir(inode);
d = erofs_d_alloc(dir, s);
- if (!IS_ERR(d)) {
+ if (IS_ERR(d)) {
+ erofs_iput(inode);
+ } else {
d->type = EROFS_FT_DIR;
d->inode = inode;
}
--
2.39.3
More information about the Linux-erofs
mailing list