public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Ingo Molnar <mingo@elte.hu>
Cc: "Pallipadi, Venkatesh" <venkatesh.pallipadi@intel.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Darren Hart <dvhltc@us.ibm.com>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH -v3] futex: fix reference leak
Date: Wed, 11 Feb 2009 16:56:42 +0100	[thread overview]
Message-ID: <1234367802.23438.183.camel@twins> (raw)
In-Reply-To: <20090211154952.GB24408@elte.hu>

On Wed, 2009-02-11 at 16:49 +0100, Ingo Molnar wrote:
> * Peter Zijlstra <peterz@infradead.org> wrote:
> 
> > So you prefer this version?
> 
> yes, with s/out_unlock_put_key/err_unlock_put_key. That's the
> only error path that goes via the tail of the function, correct?

Right, but I think one can argue that most of the out* jumps are errors.

The only non-error return is the !unqueue_me() case.

Also, since there's only one user of out_unlock_put_key, we might also
do this:

---
Index: linux-2.6/kernel/futex.c
===================================================================
--- linux-2.6.orig/kernel/futex.c
+++ linux-2.6/kernel/futex.c
@@ -1220,8 +1220,10 @@ retry:
 		goto out;
 	}
 	ret = -EWOULDBLOCK;
-	if (uval != val)
-		goto out_unlock_put_key;
+	if (uval != val) {
+		queue_unlock(&q, hb);
+		goto out_put_key;
+	}
 
 	/* Only actually queue if *uaddr contained val.  */
 	queue_me(&q, hb);
@@ -1319,10 +1321,6 @@ out_put_key:
 	put_futex_key(fshared, &q.key);
 out:
 	return ret;
-
-out_unlock_put_key:
-	queue_unlock(&q, hb);
-	goto out_put_key;
 }
 
 


  reply	other threads:[~2009-02-11 15:55 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-09 12:18 mm_alloc()'ed structure leak Catalin Marinas
2009-02-09 13:12 ` Catalin Marinas
2009-02-09 14:44 ` Catalin Marinas
2009-02-09 15:12   ` Peter Zijlstra
2009-02-09 16:45     ` Peter Zijlstra
2009-02-09 16:47       ` Peter Zijlstra
2009-02-09 17:28         ` Catalin Marinas
2009-02-09 18:26           ` [PATCH] futex: fix reference leak Peter Zijlstra
2009-02-09 18:53             ` Pallipadi, Venkatesh
2009-02-09 18:57               ` [PATCH -v2] " Peter Zijlstra
2009-02-09 20:49                 ` Darren Hart
2009-02-11 12:28                 ` Ingo Molnar
2009-02-11 15:36                   ` [PATCH -v3] " Peter Zijlstra
2009-02-11 15:49                     ` Ingo Molnar
2009-02-11 15:56                       ` Peter Zijlstra [this message]
2009-02-11 16:26                         ` Ingo Molnar
2009-02-11 17:10                           ` [PATCH -v4] " Peter Zijlstra
2009-02-11 17:24                             ` Ingo Molnar

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=1234367802.23438.183.camel@twins \
    --to=peterz@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=catalin.marinas@arm.com \
    --cc=dvhltc@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    --cc=venkatesh.pallipadi@intel.com \
    /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