aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/dlm
diff options
context:
space:
mode:
authorJoseph Qi <joseph.qi@huawei.com>2016-07-26 18:21:38 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-07-26 19:19:19 -0400
commit8ec7b17a668403435a7ab09b952e7f2eca61cf20 (patch)
tree70e3c3ece76ba60b3bbeef0961939c5ad4461dbc /fs/ocfs2/dlm
parenta8f24f1b3f0820ca6fe4b363e360f3fe7887647e (diff)
ocfs2/dlm: fix memory leak of dlm_debug_ctxt
dlm_debug_ctxt->debug_refcnt is initialized to 1 and then increased to 2 by dlm_debug_get in dlm_debug_init. But dlm_debug_put is called only once in dlm_debug_shutdown during unregister dlm, which leads to dlm_debug_ctxt leaked. Link: http://lkml.kernel.org/r/577BB755.4030900@huawei.com 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>
Diffstat (limited to 'fs/ocfs2/dlm')
-rw-r--r--fs/ocfs2/dlm/dlmdebug.c26
-rw-r--r--fs/ocfs2/dlm/dlmdebug.h1
2 files changed, 2 insertions, 25 deletions
diff --git a/fs/ocfs2/dlm/dlmdebug.c b/fs/ocfs2/dlm/dlmdebug.c
index 825136070d2c..e7b760deefae 100644
--- a/fs/ocfs2/dlm/dlmdebug.c
+++ b/fs/ocfs2/dlm/dlmdebug.c
@@ -347,26 +347,6 @@ static struct dentry *dlm_debugfs_root;
347#define DLM_DEBUGFS_PURGE_LIST "purge_list" 347#define DLM_DEBUGFS_PURGE_LIST "purge_list"
348 348
349/* begin - utils funcs */ 349/* begin - utils funcs */
350static void dlm_debug_free(struct kref *kref)
351{
352 struct dlm_debug_ctxt *dc;
353
354 dc = container_of(kref, struct dlm_debug_ctxt, debug_refcnt);
355
356 kfree(dc);
357}
358
359static void dlm_debug_put(struct dlm_debug_ctxt *dc)
360{
361 if (dc)
362 kref_put(&dc->debug_refcnt, dlm_debug_free);
363}
364
365static void dlm_debug_get(struct dlm_debug_ctxt *dc)
366{
367 kref_get(&dc->debug_refcnt);
368}
369
370static int debug_release(struct inode *inode, struct file *file) 350static int debug_release(struct inode *inode, struct file *file)
371{ 351{
372 free_page((unsigned long)file->private_data); 352 free_page((unsigned long)file->private_data);
@@ -932,11 +912,9 @@ int dlm_debug_init(struct dlm_ctxt *dlm)
932 goto bail; 912 goto bail;
933 } 913 }
934 914
935 dlm_debug_get(dc);
936 return 0; 915 return 0;
937 916
938bail: 917bail:
939 dlm_debug_shutdown(dlm);
940 return -ENOMEM; 918 return -ENOMEM;
941} 919}
942 920
@@ -949,7 +927,8 @@ void dlm_debug_shutdown(struct dlm_ctxt *dlm)
949 debugfs_remove(dc->debug_mle_dentry); 927 debugfs_remove(dc->debug_mle_dentry);
950 debugfs_remove(dc->debug_lockres_dentry); 928 debugfs_remove(dc->debug_lockres_dentry);
951 debugfs_remove(dc->debug_state_dentry); 929 debugfs_remove(dc->debug_state_dentry);
952 dlm_debug_put(dc); 930 kfree(dc);
931 dc = NULL;
953 } 932 }
954} 933}
955 934
@@ -969,7 +948,6 @@ int dlm_create_debugfs_subroot(struct dlm_ctxt *dlm)
969 mlog_errno(-ENOMEM); 948 mlog_errno(-ENOMEM);
970 goto bail; 949 goto bail;
971 } 950 }
972 kref_init(&dlm->dlm_debug_ctxt->debug_refcnt);
973 951
974 return 0; 952 return 0;
975bail: 953bail:
diff --git a/fs/ocfs2/dlm/dlmdebug.h b/fs/ocfs2/dlm/dlmdebug.h
index 1f27c4812d1a..5ced5482e7d3 100644
--- a/fs/ocfs2/dlm/dlmdebug.h
+++ b/fs/ocfs2/dlm/dlmdebug.h
@@ -30,7 +30,6 @@ void dlm_print_one_mle(struct dlm_master_list_entry *mle);
30#ifdef CONFIG_DEBUG_FS 30#ifdef CONFIG_DEBUG_FS
31 31
32struct dlm_debug_ctxt { 32struct dlm_debug_ctxt {
33 struct kref debug_refcnt;
34 struct dentry *debug_state_dentry; 33 struct dentry *debug_state_dentry;
35 struct dentry *debug_lockres_dentry; 34 struct dentry *debug_lockres_dentry;
36 struct dentry *debug_mle_dentry; 35 struct dentry *debug_mle_dentry;