[PATCH] erofs-utils: fix memory leak when erofs_fill_inode() fails

Hu Weiwen sehuww at mail.scut.edu.cn
Mon Jan 18 23:40:33 AEDT 2021


Signeo-off-by: Hu Weiwen <sehuww at mail.scut.edu.cn>
---
 lib/inode.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/inode.c b/lib/inode.c
index d6a64cc..6f6e984 100644
--- a/lib/inode.c
+++ b/lib/inode.c
@@ -868,9 +868,13 @@ struct erofs_inode *erofs_iget_from_path(const char *path, bool is_src)
 
 	ret = erofs_fill_inode(inode, &st, path);
 	if (ret)
-		return ERR_PTR(ret);
+		goto err;
 
 	return inode;
+
+err:
+	free(inode);
+	return ERR_PTR(ret);
 }
 
 void erofs_fixup_meta_blkaddr(struct erofs_inode *rootdir)
-- 
2.30.0



More information about the Linux-erofs mailing list