]> nv-tegra.nvidia Code Review - linux-2.6.git/blobdiff - net/netlink/genetlink.c
genetlink: fix netns vs. netlink table locking
[linux-2.6.git] / net / netlink / genetlink.c
index 66f6ba0bab11932c9b1302a555f9bcefb52065dd..566941e03363fbdd7591ded5ed16b41f0a903c7c 100644 (file)
@@ -176,9 +176,10 @@ int genl_register_mc_group(struct genl_family *family,
        if (family->netnsok) {
                struct net *net;
 
+               netlink_table_grab();
                rcu_read_lock();
                for_each_net_rcu(net) {
-                       err = netlink_change_ngroups(net->genl_sock,
+                       err = __netlink_change_ngroups(net->genl_sock,
                                        mc_groups_longs * BITS_PER_LONG);
                        if (err) {
                                /*
@@ -188,10 +189,12 @@ int genl_register_mc_group(struct genl_family *family,
                                 * increased on some sockets which is ok.
                                 */
                                rcu_read_unlock();
+                               netlink_table_ungrab();
                                goto out;
                        }
                }
                rcu_read_unlock();
+               netlink_table_ungrab();
        } else {
                err = netlink_change_ngroups(init_net.genl_sock,
                                             mc_groups_longs * BITS_PER_LONG);