All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chen Gang <gang.chen@asianux.com>
To: Al Viro <viro@zeniv.linux.org.uk>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Oleg Nesterov <oleg@redhat.com>,
	"Eric W. Biederman" <ebiederm@xmission.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [PATCH] kernel/exit.c: call read_unlock() when failure occurs after already called read_lock() in do_wait().
Date: Sat, 05 Oct 2013 13:53:26 +0800	[thread overview]
Message-ID: <524FA956.9080100@asianux.com> (raw)

If failure occurs after called read_lock(), need call read_unlock() too.

It can fail in multiple position, so add new tag 'fail_lock' for it
(also can let 'if' only content one jump statement).


Signed-off-by: Chen Gang <gang.chen@asianux.com>
---
 kernel/exit.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/kernel/exit.c b/kernel/exit.c
index a949819..3da5476 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -1527,11 +1527,11 @@ repeat:
 	do {
 		retval = do_wait_thread(wo, tsk);
 		if (retval)
-			goto end;
+			goto fail_lock;
 
 		retval = ptrace_do_wait(wo, tsk);
 		if (retval)
-			goto end;
+			goto fail_lock;
 
 		if (wo->wo_flags & __WNOTHREAD)
 			break;
@@ -1551,6 +1551,10 @@ end:
 	__set_current_state(TASK_RUNNING);
 	remove_wait_queue(&current->signal->wait_chldexit, &wo->child_wait);
 	return retval;
+
+fail_lock:
+	read_unlock(&tasklist_lock);
+	goto end;
 }
 
 SYSCALL_DEFINE5(waitid, int, which, pid_t, upid, struct siginfo __user *,
-- 
1.7.7.6

             reply	other threads:[~2013-10-05  5:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-05  5:53 Chen Gang [this message]
2013-10-05  6:34 ` [PATCH] kernel/exit.c: call read_unlock() when failure occurs after already called read_lock() in do_wait() Al Viro
2013-10-05  7:33   ` Chen Gang
2013-10-05 15:48     ` Al Viro
2013-10-05 16:48       ` Chen Gang

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=524FA956.9080100@asianux.com \
    --to=gang.chen@asianux.com \
    --cc=akpm@linux-foundation.org \
    --cc=ebiederm@xmission.com \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg@redhat.com \
    --cc=viro@zeniv.linux.org.uk \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.