[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1234203975.5951.143.camel@laptop>
Date: Mon, 09 Feb 2009 19:26:15 +0100
From: Peter Zijlstra <peterz@...radead.org>
To: Catalin Marinas <catalin.marinas@....com>
Cc: linux-kernel <linux-kernel@...r.kernel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Darren Hart <dvhltc@...ibm.com>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...e.hu>,
"Pallipadi, Venkatesh" <venkatesh.pallipadi@...el.com>
Subject: [PATCH] futex: fix reference leak
Venki, does this perchance solve your issue with my futex patch?
Darren, could you please have a look at this before Ingo pushes it out
to Linus?
---
Catalin noticed that (38d47c1b7075: futex: rely on
get_user_pages() for shared futexes) caused an mm_struct leak.
Some tracing with the function graph tracer quickly pointed out that
futex_wait() has exit paths with unbalanced reference counts.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@...llo.nl>
---
kernel/futex.c | 23 +++++++++++++++--------
1 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/kernel/futex.c b/kernel/futex.c
index f89d373..7b76c8e 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -1284,18 +1284,23 @@ retry:
*/
/* If we were woken (and unqueued), we succeeded, whatever. */
- if (!unqueue_me(&q))
- return 0;
- if (rem)
- return -ETIMEDOUT;
+ if (!unqueue_me(&q)) {
+ ret = 0;
+ goto out_put_key;
+ }
+ if (rem) {
+ ret = -ETIMEDOUT;
+ goto out_put_key;
+ }
/*
* We expect signal_pending(current), but another thread may
* have handled it for us already.
*/
- if (!abs_time)
- return -ERESTARTSYS;
- else {
+ if (!abs_time) {
+ ret = -ERESTARTSYS;
+ goto out_put_key;
+ } else {
struct restart_block *restart;
restart = ¤t_thread_info()->restart_block;
restart->fn = futex_wait_restart;
@@ -1309,11 +1314,13 @@ retry:
restart->futex.flags |= FLAGS_SHARED;
if (clockrt)
restart->futex.flags |= FLAGS_CLOCKRT;
- return -ERESTART_RESTARTBLOCK;
+ ret = -RESTART_RESTARTBLOCK;
+ goto out_put_key;
}
out_unlock_put_key:
queue_unlock(&q, hb);
+out_put_key:
put_futex_key(fshared, &q.key);
out:
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists