public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Amerigo Wang <amwang@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: torvalds@linux-foundation.org, Amerigo Wang <amwang@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Eric B Munson <emunson@mgebm.net>,
	David Rientjes <rientjes@google.com>,
	Dave Hansen <dave@linux.vnet.ibm.com>, Mel Gorman <mel@csn.ul.ie>
Subject: [PATCH 2/2] proc: do cleanup in m_start() rather than m_stop()
Date: Mon, 28 Mar 2011 15:07:32 +0800	[thread overview]
Message-ID: <1301296053-23589-2-git-send-email-amwang@redhat.com> (raw)
In-Reply-To: <1301296053-23589-1-git-send-email-amwang@redhat.com>

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@redhat.com>
---
 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


  reply	other threads:[~2011-03-28  7:08 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-27  9:16 BUG: unable to handle kernel paging request Anca Emanuel
2011-03-27 15:37 ` Linus Torvalds
2011-03-27 16:00   ` Américo Wang
2011-03-27 17:44     ` Anca Emanuel
2011-03-27 17:52     ` Stephen Wilson
2011-03-28  3:46       ` [Patch] proc: check error pointer returned by m_start() Amerigo Wang
2011-03-28  3:58         ` Linus Torvalds
2011-03-28  5:02           ` Cong Wang
2011-03-28  5:26           ` [Patch V2] " Amerigo Wang
2011-03-28  5:45             ` Cong Wang
2011-03-28  7:07               ` [PATCH 1/2] proc: Use IS_ERR_OR_NULL() helper Amerigo Wang
2011-03-28  7:07                 ` Amerigo Wang [this message]
2011-03-28  7:15                 ` Mike Frysinger
2011-03-28  5:46             ` [Patch V2] proc: check error pointer returned by m_start() Anca Emanuel
2011-03-28  5:49               ` Cong Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1301296053-23589-2-git-send-email-amwang@redhat.com \
    --to=amwang@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=dave@linux.vnet.ibm.com \
    --cc=emunson@mgebm.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mel@csn.ul.ie \
    --cc=rientjes@google.com \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox