Skip to content

Commit 7bd021f

Browse files
Shang XiaoJingakpm00
authored andcommitted
ocfs2: fix memory leak in ocfs2_stack_glue_init()
ocfs2_table_header should be free in ocfs2_stack_glue_init() if ocfs2_sysfs_init() failed, otherwise kmemleak will report memleak. BUG: memory leak unreferenced object 0xffff88810eeb5800 (size 128): comm "modprobe", pid 4507, jiffies 4296182506 (age 55.888s) hex dump (first 32 bytes): c0 40 14 a0 ff ff ff ff 00 00 00 00 01 00 00 00 .@.............. 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace: [<000000001e59e1cd>] __register_sysctl_table+0xca/0xef0 [<00000000c04f70f7>] 0xffffffffa0050037 [<000000001bd12912>] do_one_initcall+0xdb/0x480 [<0000000064f766c9>] do_init_module+0x1cf/0x680 [<000000002ba52db0>] load_module+0x6441/0x6f20 [<000000009772580d>] __do_sys_finit_module+0x12f/0x1c0 [<00000000380c1f22>] do_syscall_64+0x3f/0x90 [<000000004cf473bc>] entry_SYSCALL_64_after_hwframe+0x63/0xcd Link: https://lkml.kernel.org/r/[email protected] Fixes: 3878f11 ("ocfs2: Move the hb_ctl_path sysctl into the stack glue.") Signed-off-by: Shang XiaoJing <[email protected]> Reviewed-by: Joseph Qi <[email protected]> Cc: Mark Fasheh <[email protected]> Cc: Joel Becker <[email protected]> Cc: Junxiao Bi <[email protected]> Cc: Changwei Ge <[email protected]> Cc: Gang He <[email protected]> Cc: Jun Piao <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 3b2fc44 commit 7bd021f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

fs/ocfs2/stackglue.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,8 @@ static struct ctl_table_header *ocfs2_table_header;
669669

670670
static int __init ocfs2_stack_glue_init(void)
671671
{
672+
int ret;
673+
672674
strcpy(cluster_stack_name, OCFS2_STACK_PLUGIN_O2CB);
673675

674676
ocfs2_table_header = register_sysctl("fs/ocfs2/nm", ocfs2_nm_table);
@@ -678,7 +680,11 @@ static int __init ocfs2_stack_glue_init(void)
678680
return -ENOMEM; /* or something. */
679681
}
680682

681-
return ocfs2_sysfs_init();
683+
ret = ocfs2_sysfs_init();
684+
if (ret)
685+
unregister_sysctl_table(ocfs2_table_header);
686+
687+
return ret;
682688
}
683689

684690
static void __exit ocfs2_stack_glue_exit(void)

0 commit comments

Comments
 (0)