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

Hu Weiwen sehuww at mail.scut.edu.cn
Tue Jan 19 17:11:23 AEDT 2021


Signed-off-by: Hu Weiwen <sehuww at mail.scut.edu.cn>
---
fixes a typo in v1

 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