diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2005-05-03 17:43:27 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2005-05-03 17:43:27 -0400 |
commit | 96c36023434b7b6824b1da72a6b7b1ca61d7310c (patch) | |
tree | 21b46ccc9e88f5ab77e0578356ba7d86e0f5c964 /net/netlink | |
parent | 9dfa277f88388a94993b121db46b80df66f48d9e (diff) |
[NETLINK]: cb_lock does not needs ref count on sk
Here is a little optimisation for the cb_lock used by netlink_dump.
While fixing that race earlier, I noticed that the reference count
held by cb_lock is completely useless. The reason is that in order
to obtain the protection of the reference count, you have to take
the cb_lock. But the only way to take the cb_lock is through
dereferencing the socket.
That is, you must already possess a reference count on the socket
before you can take advantage of the reference count held by cb_lock.
As a corollary, we can remve the reference count held by the cb_lock.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/netlink')
-rw-r--r-- | net/netlink/af_netlink.c | 3 |
1 files changed, 0 insertions, 3 deletions
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index 29a5fd231eac..4ee392066148 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c | |||
@@ -373,7 +373,6 @@ static int netlink_release(struct socket *sock) | |||
373 | nlk->cb->done(nlk->cb); | 373 | nlk->cb->done(nlk->cb); |
374 | netlink_destroy_callback(nlk->cb); | 374 | netlink_destroy_callback(nlk->cb); |
375 | nlk->cb = NULL; | 375 | nlk->cb = NULL; |
376 | __sock_put(sk); | ||
377 | } | 376 | } |
378 | spin_unlock(&nlk->cb_lock); | 377 | spin_unlock(&nlk->cb_lock); |
379 | 378 | ||
@@ -1099,7 +1098,6 @@ static int netlink_dump(struct sock *sk) | |||
1099 | spin_unlock(&nlk->cb_lock); | 1098 | spin_unlock(&nlk->cb_lock); |
1100 | 1099 | ||
1101 | netlink_destroy_callback(cb); | 1100 | netlink_destroy_callback(cb); |
1102 | __sock_put(sk); | ||
1103 | return 0; | 1101 | return 0; |
1104 | } | 1102 | } |
1105 | 1103 | ||
@@ -1138,7 +1136,6 @@ int netlink_dump_start(struct sock *ssk, struct sk_buff *skb, | |||
1138 | return -EBUSY; | 1136 | return -EBUSY; |
1139 | } | 1137 | } |
1140 | nlk->cb = cb; | 1138 | nlk->cb = cb; |
1141 | sock_hold(sk); | ||
1142 | spin_unlock(&nlk->cb_lock); | 1139 | spin_unlock(&nlk->cb_lock); |
1143 | 1140 | ||
1144 | netlink_dump(sk); | 1141 | netlink_dump(sk); |