summaryrefslogtreecommitdiffstats
path: root/net/netlink
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2015-01-16 17:23:48 +1100
committerDavid S. Miller <davem@davemloft.net>2015-01-16 02:38:07 -0500
commit919d9db9521862d01712d9be25cd6ebfcc353eed (patch)
tree18065576ca940cb081ac5f9e2305c4dd13deee18 /net/netlink
parent57699a40b4f2694d3ee63fd5e6465ec8f600b620 (diff)
downloadlinux-stable-919d9db9521862d01712d9be25cd6ebfcc353eed.tar.gz
linux-stable-919d9db9521862d01712d9be25cd6ebfcc353eed.tar.bz2
linux-stable-919d9db9521862d01712d9be25cd6ebfcc353eed.zip
netlink: Fix netlink_insert EADDRINUSE error
The patch c5adde9468b0714a051eac7f9666f23eb10b61f7 ("netlink: eliminate nl_sk_hash_lock") introduced a bug where the EADDRINUSE error has been replaced by ENOMEM. This patch rectifies that problem. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Acked-by: Ying Xue <ying.xue@windriver.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/netlink')
-rw-r--r--net/netlink/af_netlink.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 01b702d63457..7a94185bde6b 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -1050,7 +1050,7 @@ netlink_update_listeners(struct sock *sk)
static int netlink_insert(struct sock *sk, struct net *net, u32 portid)
{
struct netlink_table *table = &nl_table[sk->sk_protocol];
- int err = -EADDRINUSE;
+ int err;
lock_sock(sk);
@@ -1065,10 +1065,13 @@ static int netlink_insert(struct sock *sk, struct net *net, u32 portid)
nlk_sk(sk)->portid = portid;
sock_hold(sk);
- if (__netlink_insert(table, sk, net))
- err = 0;
- else
+
+ err = 0;
+ if (!__netlink_insert(table, sk, net)) {
+ err = -EADDRINUSE;
sock_put(sk);
+ }
+
err:
release_sock(sk);
return err;