Or "Segmentation fault" can happen if errors are passed into
erofs_igrab().

Fixes: 21d84349e79a ("erofs-utils: rearrange on-disk metadata")
Signed-off-by: Gao Xiang <[email protected]>
---
 lib/inode.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/inode.c b/lib/inode.c
index 85eacab..a3a643f 100644
--- a/lib/inode.c
+++ b/lib/inode.c
@@ -1228,10 +1228,11 @@ struct erofs_inode 
*erofs_mkfs_build_tree_from_path(const char *path)
        LIST_HEAD(dirs);
        struct erofs_inode *inode, *root, *parent;
 
-       root = erofs_igrab(erofs_iget_from_path(path, true));
+       root = erofs_iget_from_path(path, true);
        if (IS_ERR(root))
                return root;
 
+       (void)erofs_igrab(root);
        root->i_parent = root;  /* rootdir mark */
        root->subdirs_queued = 1;
        list_add(&root->i_subdirs, &dirs);
-- 
2.24.4

Reply via email to