[Patch] fix ext2/ext3 memory leak

From: Heiko Carstens
Date: Thu Dec 09 2004 - 12:02:59 EST


Hi,

the patch below fixes an ext2/ext3 memory leak: the *_fill_super
functions allocate percpu data structures but don't free them in
*_put_super.

Thanks,
Heiko
Signed-off-by: Heiko Carstens <heiko.carstens@xxxxxxxxxx>

diffstat:
fs/ext2/super.c | 3 +++
fs/ext3/super.c | 3 +++
2 files changed, 6 insertions(+)

diff -urN linux-2.6/fs/ext2/super.c linux-2.6-patched/fs/ext2/super.c
--- linux-2.6/fs/ext2/super.c 2004-12-09 17:41:49.000000000 +0100
+++ linux-2.6-patched/fs/ext2/super.c 2004-12-09 17:42:01.000000000 +0100
@@ -122,6 +122,9 @@
brelse (sbi->s_group_desc[i]);
kfree(sbi->s_group_desc);
kfree(sbi->s_debts);
+ percpu_counter_destroy(&sbi->s_freeblocks_counter);
+ percpu_counter_destroy(&sbi->s_freeinodes_counter);
+ percpu_counter_destroy(&sbi->s_dirs_counter);
brelse (sbi->s_sbh);
sb->s_fs_info = NULL;
kfree(sbi);
diff -urN linux-2.6/fs/ext3/super.c linux-2.6-patched/fs/ext3/super.c
--- linux-2.6/fs/ext3/super.c 2004-12-09 17:41:49.000000000 +0100
+++ linux-2.6-patched/fs/ext3/super.c 2004-12-09 17:42:01.000000000 +0100
@@ -400,6 +400,9 @@
for (i = 0; i < sbi->s_gdb_count; i++)
brelse(sbi->s_group_desc[i]);
kfree(sbi->s_group_desc);
+ percpu_counter_destroy(&sbi->s_freeblocks_counter);
+ percpu_counter_destroy(&sbi->s_freeinodes_counter);
+ percpu_counter_destroy(&sbi->s_dirs_counter);
brelse(sbi->s_sbh);
#ifdef CONFIG_QUOTA
for (i = 0; i < MAXQUOTAS; i++) {