aboutsummaryrefslogtreecommitdiffstats
path: root/net/netlink/af_netlink.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/netlink/af_netlink.c')
-rw-r--r--net/netlink/af_netlink.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 21f9e30184e2..29fef558aab6 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -498,9 +498,12 @@ static int netlink_release(struct socket *sock)
498 498
499 netlink_table_grab(); 499 netlink_table_grab();
500 if (netlink_is_kernel(sk)) { 500 if (netlink_is_kernel(sk)) {
501 kfree(nl_table[sk->sk_protocol].listeners); 501 BUG_ON(nl_table[sk->sk_protocol].registered == 0);
502 nl_table[sk->sk_protocol].module = NULL; 502 if (--nl_table[sk->sk_protocol].registered == 0) {
503 nl_table[sk->sk_protocol].registered = 0; 503 kfree(nl_table[sk->sk_protocol].listeners);
504 nl_table[sk->sk_protocol].module = NULL;
505 nl_table[sk->sk_protocol].registered = 0;
506 }
504 } else if (nlk->subscriptions) 507 } else if (nlk->subscriptions)
505 netlink_update_listeners(sk); 508 netlink_update_listeners(sk);
506 netlink_table_ungrab(); 509 netlink_table_ungrab();
@@ -1389,6 +1392,7 @@ netlink_kernel_create(struct net *net, int unit, unsigned int groups,
1389 nl_table[unit].registered = 1; 1392 nl_table[unit].registered = 1;
1390 } else { 1393 } else {
1391 kfree(listeners); 1394 kfree(listeners);
1395 nl_table[unit].registered++;
1392 } 1396 }
1393 netlink_table_ungrab(); 1397 netlink_table_ungrab();
1394 1398