2021-05-10 08:57:07

by Seung-Woo Kim

[permalink] [raw]
Subject: [PATCH 1/2] fsck.f2fs: fix memory leak caused by fsck_chk_orphan_node()

With invalid node info from fsck_chk_orphan_node(), orphan_blk
and new_blk are not freed. Fix memory leak in the path.

Signed-off-by: Seung-Woo Kim <[email protected]>
---
fsck/fsck.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fsck/fsck.c b/fsck/fsck.c
index e52672032d2c..6019775dcb2d 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -1780,8 +1780,11 @@ int fsck_chk_orphan_node(struct f2fs_sb_info *sbi)
if (c.preen_mode == PREEN_MODE_1 && !c.fix_on) {
get_node_info(sbi, ino, &ni);
if (!IS_VALID_NID(sbi, ino) ||
- !IS_VALID_BLK_ADDR(sbi, ni.blk_addr))
+ !IS_VALID_BLK_ADDR(sbi, ni.blk_addr)) {
+ free(orphan_blk);
+ free(new_blk);
return -EINVAL;
+ }

continue;
}
--
2.19.2


2021-05-11 03:19:11

by Chao Yu

[permalink] [raw]
Subject: Re: [f2fs-dev] [PATCH 1/2] fsck.f2fs: fix memory leak caused by fsck_chk_orphan_node()

On 2021/5/10 16:57, Seung-Woo Kim wrote:
> With invalid node info from fsck_chk_orphan_node(), orphan_blk
> and new_blk are not freed. Fix memory leak in the path.
>
> Signed-off-by: Seung-Woo Kim <[email protected]>

Reviewed-by: Chao Yu <[email protected]>

Thanks,