summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/core/sock_diag.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
index b11593cae5a0..b1e29e18d1d6 100644
--- a/net/core/sock_diag.c
+++ b/net/core/sock_diag.c
@@ -30,7 +30,10 @@ u64 __sock_gen_cookie(struct sock *sk)
if (!res) {
u64 new = gen_cookie_next(&sock_cookie);
- atomic64_try_cmpxchg(&sk->sk_cookie, &res, new);
+ atomic64_cmpxchg(&sk->sk_cookie, res, new);
+
+ /* Another thread might have changed sk_cookie before us. */
+ res = atomic64_read(&sk->sk_cookie);
}
return res;
}