public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kernel/futex.c: notice the return value after rt_mutex_finish_proxy_lock() fails
@ 2013-08-20  3:07 Chen Gang
  2013-08-20 16:19 ` Darren Hart
  2013-09-12 14:32 ` Thomas Gleixner
  0 siblings, 2 replies; 11+ messages in thread
From: Chen Gang @ 2013-08-20  3:07 UTC (permalink / raw)
  To: Thomas Gleixner, dvhart, ccross, Mel Gorman
  Cc: Andrew Morton, linux-kernel@vger.kernel.org

rt_mutex_finish_proxy_lock() can return failure code (e.g. -EINTR,
-ETIMEDOUT).

Original implementation has already noticed about it, but not check it
before next work.

Also let coments within 80 columns to pass "./scripts/checkpatch.pl".


Signed-off-by: Chen Gang <gang.chen@asianux.com>
---
 kernel/futex.c |   30 ++++++++++++++++--------------
 1 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/kernel/futex.c b/kernel/futex.c
index c3a1a55..1a94e7d 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -2373,21 +2373,23 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, unsigned int flags,
 		ret = rt_mutex_finish_proxy_lock(pi_mutex, to, &rt_waiter, 1);
 		debug_rt_mutex_free_waiter(&rt_waiter);
 
-		spin_lock(q.lock_ptr);
-		/*
-		 * Fixup the pi_state owner and possibly acquire the lock if we
-		 * haven't already.
-		 */
-		res = fixup_owner(uaddr2, &q, !ret);
-		/*
-		 * If fixup_owner() returned an error, proprogate that.  If it
-		 * acquired the lock, clear -ETIMEDOUT or -EINTR.
-		 */
-		if (res)
-			ret = (res < 0) ? res : 0;
+		if (!ret) {
+			spin_lock(q.lock_ptr);
+			/*
+			 * Fixup the pi_state owner and possibly acquire the
+			 * lock if we haven't already.
+			 */
+			res = fixup_owner(uaddr2, &q, !ret);
+			/*
+			 * If fixup_owner() returned an error, proprogate that.
+			 * If it acquired the lock, clear -ETIMEDOUT or -EINTR.
+			 */
+			if (res)
+				ret = (res < 0) ? res : 0;
 
-		/* Unqueue and drop the lock. */
-		unqueue_me_pi(&q);
+			/* Unqueue and drop the lock. */
+			unqueue_me_pi(&q);
+		}
 	}
 
 	/*
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2013-10-07 22:06 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-20  3:07 [PATCH] kernel/futex.c: notice the return value after rt_mutex_finish_proxy_lock() fails Chen Gang
2013-08-20 16:19 ` Darren Hart
2013-08-21  3:48   ` Chen Gang
2013-09-03  5:10     ` Chen Gang
2013-09-12 14:32 ` Thomas Gleixner
2013-09-12 22:37   ` Darren Hart
2013-09-12 23:36     ` Thomas Gleixner
2013-09-13  1:52       ` Chen Gang
2013-10-07  5:14         ` Chen Gang
2013-10-07 22:05           ` Chen Gang
2013-09-13  1:27     ` Chen Gang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox