--- a/net/ipv4/netfilter/ipt_CLUSTERIP.c +++ b/net/ipv4/netfilter/ipt_CLUSTERIP.c @@ -230,17 +230,6 @@ clusterip_config_init(struct net *net, const struct ipt_clusterip_tgt_info *i, refcount_set(&c->refcount, 1); refcount_set(&c->entries, 1); - spin_lock_bh(&cn->lock); - if (__clusterip_config_find(net, ip)) { - spin_unlock_bh(&cn->lock); - kfree(c); - - return ERR_PTR(-EBUSY); - } - - list_add_rcu(&c->list, &cn->configs); - spin_unlock_bh(&cn->lock); - #ifdef CONFIG_PROC_FS { char buffer[16]; @@ -257,20 +246,31 @@ clusterip_config_init(struct net *net, const struct ipt_clusterip_tgt_info *i, } #endif + spin_lock_bh(&cn->lock); + if (__clusterip_config_find(net, ip)) { + spin_unlock_bh(&cn->lock); + err = -EBUSY; + goto err_remove_pte: + } + + list_add_rcu(&c->list, &cn->configs); + spin_unlock_bh(&cn->lock); + c->notifier.notifier_call = clusterip_netdev_event; err = register_netdevice_notifier(&c->notifier); if (!err) return c; + spin_lock_bh(&cn->lock); + list_del_rcu(&c->list); + spin_unlock_bh(&cn->lock); + +err_remove_pte: #ifdef CONFIG_PROC_FS proc_remove(c->pde); err: #endif - spin_lock_bh(&cn->lock); - list_del_rcu(&c->list); - spin_unlock_bh(&cn->lock); kfree(c); - return ERR_PTR(err); }