Skip to contentSkip to conversation

futex: fix futex_wait_setup key handling

PATCH Superseded Darren Hart 2 participants 2 messages Apr 10, 2009

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 futex: fix futex_wait_setup key handling

If the get_futex_key() call were to fail, the existing code would try and put_futex_key() prior to returning. This patch makes sure we only put_futex_key() if get_futex_key() succeeded.

Please apply to -rt and to tip:/core/futexes.

---

 kernel/futex.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
kernel/futex.c +3 -2
index 185c981..4357f06 100644
@@ -1657,7 +1657,7 @@ retry_private:
 
 		ret = get_user(uval, uaddr);
 		if (ret)
-			goto out;
+			goto out_put_key;
 
 		if (!fshared)
 			goto retry_private;
@@ -1671,9 +1671,10 @@ retry_private:
 		ret = -EWOULDBLOCK;
 	}
 
-out:
+out_put_key:
 	if (ret)
 		put_futex_key(fshared, &q->key);
+out:
 	return ret;
 }
 
#1 lore raw
Quoted 29 lines · Darren Hart

If the get_futex_key() call were to fail, the existing code would try and put_futex_key() prior to returning. This patch makes sure we only put_futex_key() if get_futex_key() succeeded.

Please apply to -rt and to tip:/core/futexes.

---

 kernel/futex.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
kernel/futex.c +1 -1
index 185c981..4357f06 100644
@@ -1657,7 +1657,7 @@ retry_private:
 
 		ret = get_user(uval, uaddr);
 		if (ret)
-			goto out;
+			goto out_put_key;
 
 		if (!fshared)
 			goto retry_private;

kernel/futex.c retry_private: · line 1678

Quoted 9 lines
kernel/futex.c +2 -1
@@ -1671,9 +1671,10 @@ retry_private:
 		ret = -EWOULDBLOCK;
 	}
 
-out:
+out_put_key:
 	if (ret)
 		put_futex_key(fshared, &q->key);
+out:
 	return ret;

Yikes. Can we please convert the places which do "goto out;" to "return ret;" ?

Thanks,

tglx