All of lore.kernel.org
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH 1/3] fsck.f2fs: fix to avoid memory leak reported by LeakSanitizer
@ 2026-08-15  0:54 Chao Yu via Linux-f2fs-devel
  2026-08-15  0:54 ` [f2fs-dev] [PATCH 2/3] fsck.f2fs: sanity check i_extra_isize correctly Chao Yu via Linux-f2fs-devel
  2026-08-15  0:54 ` [f2fs-dev] [PATCH 3/3] fsck.f2fs: sanity check quota file size in v2_init_io Chao Yu via Linux-f2fs-devel
  0 siblings, 2 replies; 3+ messages in thread
From: Chao Yu via Linux-f2fs-devel @ 2026-08-15  0:54 UTC (permalink / raw)
  To: jaegeuk; +Cc: linux-f2fs-devel

==5957==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 4096 byte(s) in 1 object(s) allocated from:
    #0 0x7f08b78bc340 in calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:77
    #1 0x55b9e0fcbcc7 in update_data_blkaddr /share/tools-f2fs/fsck/mount.c:2523

SUMMARY: AddressSanitizer: 4096 byte(s) leaked in 1 allocation(s).

When a process calls exit(), the C runtime executes all registered
atexit handlers.
AddressSanitizer / LeakSanitizer (LSan) hooks into exit() to inspect
the heap, it checks whether all memory allocated via malloc() / calloc()
was explicitly released.

Relocate sanity check and ASSERT(0) before node block allocation to fix
this issue.

Signed-off-by: Chao Yu <chao@kernel.org>
---
 fsck/mount.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/fsck/mount.c b/fsck/mount.c
index 2e7ea45..26f213e 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -2520,22 +2520,22 @@ void update_data_blkaddr(struct f2fs_sb_info *sbi, nid_t nid,
 	if (node_blk == NULL) {
 		struct seg_entry *se;
 
-		node_blk = (struct f2fs_node *)calloc(F2FS_BLKSIZE, 1);
-		ASSERT(node_blk);
-
 		get_node_info(sbi, nid, &ni);
 
-		/* read node_block */
-		ret = dev_read_block(node_blk, ni.blk_addr);
-		ASSERT(ret >= 0);
-		node_blk_alloced = true;
-
 		se = get_seg_entry(sbi, GET_SEGNO(sbi, ni.blk_addr));
 		if (IS_DATASEG(se->type)) {
 			ERR_MSG("NAT and SIT is inconsistent: ino: %u, nid: %u, blkaddr: %u, segtype: %d",
 				ni.ino, ni.nid, ni.blk_addr, se->type);
 			ASSERT(0);
 		}
+
+		node_blk = (struct f2fs_node *)calloc(F2FS_BLKSIZE, 1);
+		ASSERT(node_blk);
+
+		/* read node_block */
+		ret = dev_read_block(node_blk, ni.blk_addr);
+		ASSERT(ret >= 0);
+		node_blk_alloced = true;
 	}
 
 	/* check its block address */
-- 
2.49.0



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

end of thread, other threads:[~2026-08-15  0:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-15  0:54 [f2fs-dev] [PATCH 1/3] fsck.f2fs: fix to avoid memory leak reported by LeakSanitizer Chao Yu via Linux-f2fs-devel
2026-08-15  0:54 ` [f2fs-dev] [PATCH 2/3] fsck.f2fs: sanity check i_extra_isize correctly Chao Yu via Linux-f2fs-devel
2026-08-15  0:54 ` [f2fs-dev] [PATCH 3/3] fsck.f2fs: sanity check quota file size in v2_init_io Chao Yu via Linux-f2fs-devel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.