Skip to content

Commit 4a70e25

Browse files
chaseyuJaegeuk Kim
authored andcommitted
f2fs: fix memory leak of percpu counter in fill_super()
In fill_super -> init_percpu_info, we should destroy percpu counter in error path, otherwise memory allcoated for percpu counter will leak. Signed-off-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 0b2103e commit 4a70e25

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

fs/f2fs/super.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2458,8 +2458,12 @@ static int init_percpu_info(struct f2fs_sb_info *sbi)
24582458
if (err)
24592459
return err;
24602460

2461-
return percpu_counter_init(&sbi->total_valid_inode_count, 0,
2461+
err = percpu_counter_init(&sbi->total_valid_inode_count, 0,
24622462
GFP_KERNEL);
2463+
if (err)
2464+
percpu_counter_destroy(&sbi->alloc_valid_block_count);
2465+
2466+
return err;
24632467
}
24642468

24652469
#ifdef CONFIG_BLK_DEV_ZONED

0 commit comments

Comments
 (0)