Skip to content

Commit a4a1dfa

Browse files
josephhztorvalds
authored andcommitted
ocfs2/cluster: fix memory leak in o2hb_region_release
o2hb_region_release currently doesn't free o2hb_debug_buf hr_db_elapsed_time and hr_db_pinned malloced in o2hb_debug_create. Also we should call debugfs_remove before freeing its data, to prevent the risk accessing debugfs rightly after its data has been freed. Signed-off-by: Joseph Qi <joseph.qi@huawei.com> Reviewed-by: Jiufei Xue <xuejiufei@huawei.com> Cc: Mark Fasheh <mfasheh@suse.de> Cc: Joel Becker <jlbec@evilplan.org> Cc: Junxiao Bi <junxiao.bi@oracle.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 72676bb commit a4a1dfa

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

fs/ocfs2/cluster/heartbeat.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,15 +1254,15 @@ static const struct file_operations o2hb_debug_fops = {
12541254

12551255
void o2hb_exit(void)
12561256
{
1257-
kfree(o2hb_db_livenodes);
1258-
kfree(o2hb_db_liveregions);
1259-
kfree(o2hb_db_quorumregions);
1260-
kfree(o2hb_db_failedregions);
12611257
debugfs_remove(o2hb_debug_failedregions);
12621258
debugfs_remove(o2hb_debug_quorumregions);
12631259
debugfs_remove(o2hb_debug_liveregions);
12641260
debugfs_remove(o2hb_debug_livenodes);
12651261
debugfs_remove(o2hb_debug_dir);
1262+
kfree(o2hb_db_livenodes);
1263+
kfree(o2hb_db_liveregions);
1264+
kfree(o2hb_db_quorumregions);
1265+
kfree(o2hb_db_failedregions);
12661266
}
12671267

12681268
static struct dentry *o2hb_debug_create(const char *name, struct dentry *dir,
@@ -1438,13 +1438,15 @@ static void o2hb_region_release(struct config_item *item)
14381438

14391439
kfree(reg->hr_slots);
14401440

1441-
kfree(reg->hr_db_regnum);
1442-
kfree(reg->hr_db_livenodes);
14431441
debugfs_remove(reg->hr_debug_livenodes);
14441442
debugfs_remove(reg->hr_debug_regnum);
14451443
debugfs_remove(reg->hr_debug_elapsed_time);
14461444
debugfs_remove(reg->hr_debug_pinned);
14471445
debugfs_remove(reg->hr_debug_dir);
1446+
kfree(reg->hr_db_livenodes);
1447+
kfree(reg->hr_db_regnum);
1448+
kfree(reg->hr_debug_elapsed_time);
1449+
kfree(reg->hr_debug_pinned);
14481450

14491451
spin_lock(&o2hb_live_lock);
14501452
list_del(&reg->hr_all_item);

0 commit comments

Comments
 (0)