Re: [PATCH -v3] futex: fix reference leak

From: Peter Zijlstra
Date: Wed Feb 11 2009 - 10:55:17 EST


On Wed, 2009-02-11 at 16:49 +0100, Ingo Molnar wrote:
> * Peter Zijlstra <peterz@xxxxxxxxxxxxx> 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;
}



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/