[PATCH 2/2] proc: do cleanup in m_start() rather than m_stop()

From: Amerigo Wang
Date: Mon Mar 28 2011 - 03:08:32 EST


In the future, we will not call ->stop() anymore when ->start() fails,
so ->start() is responsible to do cleanups within itself.

Signed-off-by: Amerigo Wang <amwang@xxxxxxxxxx>
---
fs/proc/task_mmu.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 3c06570..9ebbe20 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -124,8 +124,10 @@ static void *m_start(struct seq_file *m, loff_t *pos)
return ERR_PTR(-ESRCH);

mm = mm_for_maps(priv->task);
- if (IS_ERR_OR_NULL(mm))
+ if (IS_ERR_OR_NULL(mm)) {
+ put_task_struct(priv->task);
return mm;
+ }
down_read(&mm->mmap_sem);

tail_vma = get_gate_vma(priv->task->mm);
@@ -182,8 +184,9 @@ static void m_stop(struct seq_file *m, void *v)
struct proc_maps_private *priv = m->private;
struct vm_area_struct *vma = v;

- if (!IS_ERR_OR_NULL(vma))
- vma_stop(priv, vma);
+ if (IS_ERR_OR_NULL(vma))
+ return;
+ vma_stop(priv, vma);
if (priv->task)
put_task_struct(priv->task);
}
--
1.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/