Skip to contentSkip to conversation

erofs-utils: bail out properly if erofs_iget_from_path(root) fails

PATCH New Gao Xiang 1 participant 1 message Sep 1, 2023 Library code

lore
Share & tools
lore

Gao Xiang

author
#0 lore raw

PATCH 1/1 erofs-utils: bail out properly if erofs_iget_from_path(root) fails

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

Fixes 21d84349e79a ("erofs-utils: rearrange on-disk metadata")
---
 lib/inode.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/inode.c +2 -1
index 85eacab..a3a643f 100644
@@ -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);
Signature · 1 line
2.24.4