Skip to contentSkip to conversation

ocfs2: fix possible memory leak in dlm_process_recovery_data

PATCH Superseded Qijiang (Joseph) 3 participants 3 messages May 1, 2013 – May 2, 2013 OCFS2

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 fs/ocfs2/dlm/dlmrecovery.c |    6 ++++++
 1 file changed, 6 insertions(+)
fs/ocfs2/dlm/dlmrecovery.c +6 -0
index eeac97b..93de2e0 100644
@@ -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

#1 lore raw

PATCH 1/1 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.

Quoted 1 line · Qijiang (Joseph)

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)

Quoted 29 lines
---
 fs/ocfs2/dlm/dlmrecovery.c |    6 ++++++
 1 file changed, 6 insertions(+)
fs/ocfs2/dlm/dlmrecovery.c +6 -1
index eeac97b..93de2e0 100644
@@ -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

#2 lore raw

PATCH 1/1 ocfs2: fix possible memory leak in dlm_process_recovery_data

Hi Qijiang,

Thanks for your patch.

Quoted 8 lines · Li Zefan

This patch is mangled. Please read Documentation/email-clients.txt and configure your email client properly, and then re-send the patch.

Quoted 1 line · Qijiang (Joseph)

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)

Yes, it's better to break the description up to 72 bytes per line.

Quoted 8 lines
Quoted 8 lines
---
 fs/ocfs2/dlm/dlmrecovery.c |    6 ++++++
 1 file changed, 6 insertions(+)
Quoted 10 lines

fs/ocfs2/dlm/dlmrecovery.c skip_lvb: · line 1978

Quoted 10 lines
fs/ocfs2/dlm/dlmrecovery.c +2 -0
index eeac97b..93de2e0 100644
@@ -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 */
		/* Free the new lock if it is bad */
Quoted 1 line

fs/ocfs2/dlm/dlmrecovery.c skip_lvb: · line 1979

Quoted 1 line
fs/ocfs2/dlm/dlmrecovery.c +1 -0
+           if (newlock) {

Hmm? newlock should must be allocated come to this point, so we don't need to check it up again.

Quoted 6 lines

fs/ocfs2/dlm/dlmrecovery.c skip_lvb: · line 1985

Quoted 6 lines
fs/ocfs2/dlm/dlmrecovery.c +3 -0
+               dlm_lock_put(newlock);
+               newlock = NULL;
+           }
        }
        spin_unlock(&res->spinlock);
    }

Otherwise this patch looks good to me, you can add:

BTW, looks your original post was ate by the mailing list somehow since I can not found it out from OCFS2-DEV archives of May:
https://oss.oracle.com/pipermail/ocfs2-devel/2013-May/thread.html

There should be something wrong with the mailing list but not yours.:)

In order to avoid missing any upstream patch, could you please add "Andrew Morton <[email protected]>" as well as OCFS2 maintainers (Joel & Mark) to the Cc list for the next round?

Recently we have follow up a new process for syncing up OCFS2 upstream patches:
Andrew will help us merging patch to MM tree once it got an "Acked-by" from Joel and Mark.

Thanks,
-Jeff