[PATCH v2 1/1] erofs-utils: fix use after free in closedir

Huang Jianan huangjianan at oppo.com
Fri Nov 27 22:06:16 AEDT 2020


No need to closedir _dir again since it has been released.

Signed-off-by: Huang Jianan <huangjianan at oppo.com>
Signed-off-by: Guo Weichao <guoweichao at oppo.com>
---
 lib/inode.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lib/inode.c b/lib/inode.c
index eb2e0f2..388d21d 100644
--- a/lib/inode.c
+++ b/lib/inode.c
@@ -958,11 +958,11 @@ struct erofs_inode *erofs_mkfs_build_tree(struct erofs_inode *dir)
 
 	ret = erofs_prepare_dir_file(dir);
 	if (ret)
-		goto err_closedir;
+		goto err;
 
 	ret = erofs_prepare_inode_buffer(dir);
 	if (ret)
-		goto err_closedir;
+		goto err;
 
 	if (IS_ROOT(dir))
 		erofs_fixup_meta_blkaddr(dir);
@@ -988,7 +988,7 @@ struct erofs_inode *erofs_mkfs_build_tree(struct erofs_inode *dir)
 fail:
 			d->inode = NULL;
 			d->type = EROFS_FT_UNKNOWN;
-			goto err_closedir;
+			goto err;
 		}
 
 		d->type = erofs_type_by_mode[d->inode->i_mode >> S_SHIFT];
@@ -1003,6 +1003,7 @@ fail:
 
 err_closedir:
 	closedir(_dir);
+err:
 	return ERR_PTR(ret);
 }
 
-- 
2.25.1



More information about the Linux-erofs mailing list