Skip to content

Commit

Permalink
netlink: Fix netlink_insert EADDRINUSE error
Browse files Browse the repository at this point in the history
The patch c5adde9 ("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>
  • Loading branch information
Herbert Xu authored and David S. Miller committed Jan 16, 2015
1 parent 57699a4 commit 919d9db
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions net/netlink/af_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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;
Expand Down

0 comments on commit 919d9db

Please sign in to comment.