linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] fsck.f2fs: fix memory leak caused by fsck_chk_orphan_node()
       [not found] <CGME20210510085419epcas1p1e16c3966fc1b7b9f28a797eaa588f3ba@epcas1p1.samsung.com>
@ 2021-05-10  8:57 ` Seung-Woo Kim
       [not found]   ` <CGME20210510085419epcas1p3e72ea9d956bcf811167b14e06fb08149@epcas1p3.samsung.com>
  2021-05-11  3:18   ` [f2fs-dev] [PATCH 1/2] fsck.f2fs: fix memory leak caused by fsck_chk_orphan_node() Chao Yu
  0 siblings, 2 replies; 4+ messages in thread
From: Seung-Woo Kim @ 2021-05-10  8:57 UTC (permalink / raw)
  To: jaegeuk, linux-f2fs-devel; +Cc: linux-kernel, chao, sw0312.kim

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 <sw0312.kim@samsung.com>
---
 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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] dump.f2fs: fix memory leak caused by dump_node_blk()
       [not found]   ` <CGME20210510085419epcas1p3e72ea9d956bcf811167b14e06fb08149@epcas1p3.samsung.com>
@ 2021-05-10  8:57     ` Seung-Woo Kim
  2021-05-11  3:19       ` [f2fs-dev] " Chao Yu
  0 siblings, 1 reply; 4+ messages in thread
From: Seung-Woo Kim @ 2021-05-10  8:57 UTC (permalink / raw)
  To: jaegeuk, linux-f2fs-devel; +Cc: linux-kernel, chao, sw0312.kim

Fix to free node_blk when nid is 0 from dump_node_blk().

Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
---
 fsck/dump.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fsck/dump.c b/fsck/dump.c
index 055ce09bb1cf..042a2e52edca 100644
--- a/fsck/dump.c
+++ b/fsck/dump.c
@@ -278,7 +278,7 @@ static void dump_node_blk(struct f2fs_sb_info *sbi, int ntype,
 
 	if (nid == 0) {
 		*ofs += skip;
-		return;
+		goto out;
 	}
 
 	for (i = 0; i < idx; i++, (*ofs)++) {
@@ -297,6 +297,7 @@ static void dump_node_blk(struct f2fs_sb_info *sbi, int ntype,
 			break;
 		}
 	}
+out:
 	free(node_blk);
 }
 
-- 
2.19.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [f2fs-dev] [PATCH 1/2] fsck.f2fs: fix memory leak caused by fsck_chk_orphan_node()
  2021-05-10  8:57 ` [PATCH 1/2] fsck.f2fs: fix memory leak caused by fsck_chk_orphan_node() Seung-Woo Kim
       [not found]   ` <CGME20210510085419epcas1p3e72ea9d956bcf811167b14e06fb08149@epcas1p3.samsung.com>
@ 2021-05-11  3:18   ` Chao Yu
  1 sibling, 0 replies; 4+ messages in thread
From: Chao Yu @ 2021-05-11  3:18 UTC (permalink / raw)
  To: Seung-Woo Kim, jaegeuk, linux-f2fs-devel; +Cc: linux-kernel

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 <sw0312.kim@samsung.com>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [f2fs-dev] [PATCH 2/2] dump.f2fs: fix memory leak caused by dump_node_blk()
  2021-05-10  8:57     ` [PATCH 2/2] dump.f2fs: fix memory leak caused by dump_node_blk() Seung-Woo Kim
@ 2021-05-11  3:19       ` Chao Yu
  0 siblings, 0 replies; 4+ messages in thread
From: Chao Yu @ 2021-05-11  3:19 UTC (permalink / raw)
  To: Seung-Woo Kim, jaegeuk, linux-f2fs-devel; +Cc: linux-kernel

On 2021/5/10 16:57, Seung-Woo Kim wrote:
> Fix to free node_blk when nid is 0 from dump_node_blk().
> 
> Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-05-11  3:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20210510085419epcas1p1e16c3966fc1b7b9f28a797eaa588f3ba@epcas1p1.samsung.com>
2021-05-10  8:57 ` [PATCH 1/2] fsck.f2fs: fix memory leak caused by fsck_chk_orphan_node() Seung-Woo Kim
     [not found]   ` <CGME20210510085419epcas1p3e72ea9d956bcf811167b14e06fb08149@epcas1p3.samsung.com>
2021-05-10  8:57     ` [PATCH 2/2] dump.f2fs: fix memory leak caused by dump_node_blk() Seung-Woo Kim
2021-05-11  3:19       ` [f2fs-dev] " Chao Yu
2021-05-11  3:18   ` [f2fs-dev] [PATCH 1/2] fsck.f2fs: fix memory leak caused by fsck_chk_orphan_node() Chao Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).