<div dir="ltr"><div><div><div>Do you know under what conditions does it create a new lock when it should not?<br></div><br></div><div>This code should only trigger if the lockres is/was mastered on another node.<br>Meaning this node will not know about the newlock. Meaning that code should<br>
never trigger.<br><br>1949                         if (lock-&gt;ml.cookie == ml-&gt;cookie) {<br></div><div>This if looks hacky.<br></div><div><br></div><div>If you have a reproducible case, it may be worthwhile to get some traces to see<br>
</div><div>under what conditions this happens. Should be straight forward after that.<br><br></div><div>Thanks<br>Sunil<br></div></div><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, May 2, 2013 at 5:56 AM, Joseph Qi <span dir="ltr">&lt;<a href="mailto:joseph.qi@huawei.com" target="_blank">joseph.qi@huawei.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div text="#000000" bgcolor="#FFFFFF">
    <small> </small>
    <pre><small><big><big><small>We found a possible memory leak in dlm_process_recovery_data when doing
code review. In dlm_process_recovery_data, it creates newlock each time,
but don&#39;t free when it is bad, and then it will lead to memory leak.

Cc: <a href="mailto:stable@vger.kernel.org" target="_blank">stable@vger.kernel.org</a>
Signed-off-by: Joseph Qi <a href="mailto:joseph.qi@huawei.com" target="_blank">&lt;joseph.qi@huawei.com&gt;</a>
Reviewed-by: Jie Liu <a href="mailto:jeff.liu@oracle.com" target="_blank">&lt;jeff.liu@oracle.com&gt;</a>

---
 fs/ocfs2/dlm/dlmrecovery.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c
index eeac97b..9f08523 100644
--- a/fs/ocfs2/dlm/dlmrecovery.c
+++ b/fs/ocfs2/dlm/dlmrecovery.c
@@ -1974,6 +1974,10 @@ skip_lvb:
                              res-&gt;lockname.len, res-&gt;<a href="http://lockname.name" target="_blank">lockname.name</a>, ml-&gt;node);
                         dlm_lockres_set_refmap_bit(dlm, res, ml-&gt;node);
                         added++;
+                } else {
+                        /* Free the new lock if it is bad */
+                        dlm_lock_put(newlock);
+                        newlock = NULL;
                 }
                 spin_unlock(&amp;res-&gt;spinlock);
         }
-- 
1.7.9.7</small>

</big></big></small></pre>
    <small> </small>
  </div>

<br>_______________________________________________<br>
Ocfs2-devel mailing list<br>
<a href="mailto:Ocfs2-devel@oss.oracle.com">Ocfs2-devel@oss.oracle.com</a><br>
<a href="https://oss.oracle.com/mailman/listinfo/ocfs2-devel" target="_blank">https://oss.oracle.com/mailman/listinfo/ocfs2-devel</a><br></blockquote></div><br></div>