Commit 919d9db9 authored by Herbert Xu's avatar Herbert Xu Committed by David S. Miller

netlink: Fix netlink_insert EADDRINUSE error

The patch c5adde94 ("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: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Acked-by: default avatarYing Xue <ying.xue@windriver.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 57699a40
......@@ -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
if (!__netlink_insert(table, sk, net)) {
err = -EADDRINUSE;
sock_put(sk);
}
err:
release_sock(sk);
return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment