Qijiang (Joseph)
2013-May-01 04:06 UTC
[Ocfs2-devel] [PATCH] ocfs2: fix possible memory leak in dlm_process_recovery_data
We create newlock each time in dlm_process_recovery_data, but we don't free it when it is bad, and then it will lead to memory leak. Signed-off-by: Joseph Qi <joseph.qi at huawei.com> --- fs/ocfs2/dlm/dlmrecovery.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c index eeac97b..93de2e0 100644 --- a/fs/ocfs2/dlm/dlmrecovery.c +++ b/fs/ocfs2/dlm/dlmrecovery.c @@ -1974,6 +1974,12 @@ skip_lvb: res->lockname.len, res->lockname.name, ml->node); dlm_lockres_set_refmap_bit(dlm, res, ml->node); added++; + } else { + /* should free newlock if it is bad */ + if (newlock) { + dlm_lock_put(newlock); + newlock = NULL; + } } spin_unlock(&res->spinlock); } -- 1.7.9.7
Li Zefan
2013-May-02 03:14 UTC
[Ocfs2-devel] [PATCH] ocfs2: fix possible memory leak in dlm_process_recovery_data
This patch is mangled. Please read Documentation/email-clients.txt and configure your email client properly, and then re-send the patch. On 2013/5/1 12:06, Qijiang (Joseph) wrote:> We create newlock each time in dlm_process_recovery_data, but we don't free it when it is bad, and then it will lead to memory leak.The leading spaces are not need, and please break into lines within 80 characters. (or 72 to be more strict)> > Signed-off-by: Joseph Qi <joseph.qi at huawei.com> > > --- > fs/ocfs2/dlm/dlmrecovery.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c > index eeac97b..93de2e0 100644 > --- a/fs/ocfs2/dlm/dlmrecovery.c > +++ b/fs/ocfs2/dlm/dlmrecovery.c > @@ -1974,6 +1974,12 @@ skip_lvb: > res->lockname.len, res->lockname.name, ml->node); > dlm_lockres_set_refmap_bit(dlm, res, ml->node); > added++; > + } else { > + /* should free newlock if it is bad */ > + if (newlock) { > + dlm_lock_put(newlock); > + newlock = NULL; > + } > } > spin_unlock(&res->spinlock); > } > -- > 1.7.9.7 > > >