diff options
-rw-r--r-- | net/netlink/af_netlink.c | 11 |
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; |