The following commit has been merged in the merge/master branch: commit 449683cb98e364ee1848bce42aa0ca4f9c9732c7 Merge: fd9fec7e93906b3109b84a3c79513944cac71b45 8013ae257447c99d7ba037967458f91ceb4051ae Author: Marek Lindner mareklindner@neomailbox.ch Date: Tue May 3 01:34:46 2016 +0800
Merge branch 'maint' into next
diff --combined net/batman-adv/originator.c index 1ff4ee4,28241a4d..7f51bc2 --- a/net/batman-adv/originator.c +++ b/net/batman-adv/originator.c @@@ -54,9 -54,9 +54,9 @@@ static void batadv_purge_orig(struct wo * @node: node in the local table * @data2: second object to compare the node to * - * Return: 1 if they are the same originator + * Return: true if they are the same originator */ -int batadv_compare_orig(const struct hlist_node *node, const void *data2) +bool batadv_compare_orig(const struct hlist_node *node, const void *data2) { const void *data1 = container_of(node, struct batadv_orig_node, hash_entry); @@@ -282,7 -282,7 +282,7 @@@ void batadv_neigh_node_put(struct batad }
/** - * batadv_orig_node_get_router - router to the originator depending on iface + * batadv_orig_router_get - router to the originator depending on iface * @orig_node: the orig node for the router * @if_outgoing: the interface where the payload packet has been received or * the OGM should be sent to @@@ -374,8 -374,12 +374,8 @@@ batadv_orig_ifinfo_new(struct batadv_or if (!orig_ifinfo) goto out;
- if (if_outgoing != BATADV_IF_DEFAULT && - !kref_get_unless_zero(&if_outgoing->refcount)) { - kfree(orig_ifinfo); - orig_ifinfo = NULL; - goto out; - } + if (if_outgoing != BATADV_IF_DEFAULT) + kref_get(&if_outgoing->refcount);
reset_time = jiffies - 1; reset_time -= msecs_to_jiffies(BATADV_RESET_PROTECTION_MS); @@@ -451,8 -455,11 +451,8 @@@ batadv_neigh_ifinfo_new(struct batadv_n if (!neigh_ifinfo) goto out;
- if (if_outgoing && !kref_get_unless_zero(&if_outgoing->refcount)) { - kfree(neigh_ifinfo); - neigh_ifinfo = NULL; - goto out; - } + if (if_outgoing) + kref_get(&if_outgoing->refcount);
INIT_HLIST_NODE(&neigh_ifinfo->list); kref_init(&neigh_ifinfo->refcount); @@@ -525,11 -532,15 +525,11 @@@ batadv_hardif_neigh_create(struct batad if (hardif_neigh) goto out;
- if (!kref_get_unless_zero(&hard_iface->refcount)) - goto out; - hardif_neigh = kzalloc(sizeof(*hardif_neigh), GFP_ATOMIC); - if (!hardif_neigh) { - batadv_hardif_put(hard_iface); + if (!hardif_neigh) goto out; - }
+ kref_get(&hard_iface->refcount); INIT_HLIST_NODE(&hardif_neigh->list); ether_addr_copy(hardif_neigh->addr, neigh_addr); hardif_neigh->if_incoming = hard_iface; @@@ -619,6 -630,8 +619,8 @@@ batadv_neigh_node_new(struct batadv_ori struct batadv_neigh_node *neigh_node; struct batadv_hardif_neigh_node *hardif_neigh = NULL;
+ spin_lock_bh(&orig_node->neigh_list_lock); + neigh_node = batadv_neigh_node_get(orig_node, hard_iface, neigh_addr); if (neigh_node) goto out; @@@ -632,11 -645,16 +634,11 @@@ if (!neigh_node) goto out;
- if (!kref_get_unless_zero(&hard_iface->refcount)) { - kfree(neigh_node); - neigh_node = NULL; - goto out; - } - INIT_HLIST_NODE(&neigh_node->list); INIT_HLIST_HEAD(&neigh_node->ifinfo_list); spin_lock_init(&neigh_node->ifinfo_lock);
+ kref_get(&hard_iface->refcount); ether_addr_copy(neigh_node->addr, neigh_addr); neigh_node->if_incoming = hard_iface; neigh_node->orig_node = orig_node; @@@ -650,15 -668,15 +652,15 @@@ kref_init(&neigh_node->refcount); kref_get(&neigh_node->refcount);
- spin_lock_bh(&orig_node->neigh_list_lock); hlist_add_head_rcu(&neigh_node->list, &orig_node->neigh_list); - spin_unlock_bh(&orig_node->neigh_list_lock);
batadv_dbg(BATADV_DBG_BATMAN, orig_node->bat_priv, "Creating new neighbor %pM for orig_node %pM on interface %s\n", neigh_addr, orig_node->orig, hard_iface->net_dev->name);
out: + spin_unlock_bh(&orig_node->neigh_list_lock); + if (hardif_neigh) batadv_hardif_neigh_put(hardif_neigh); return neigh_node; @@@ -1144,9 -1162,6 +1146,9 @@@ static bool batadv_purge_orig_node(stru if (hard_iface->soft_iface != bat_priv->soft_iface) continue;
+ if (!kref_get_unless_zero(&hard_iface->refcount)) + continue; + best_neigh_node = batadv_find_best_neighbor(bat_priv, orig_node, hard_iface); @@@ -1154,8 -1169,6 +1156,8 @@@ best_neigh_node); if (best_neigh_node) batadv_neigh_node_put(best_neigh_node); + + batadv_hardif_put(hard_iface); } rcu_read_unlock();
@@@ -1206,7 -1219,7 +1208,7 @@@ static void batadv_purge_orig(struct wo struct delayed_work *delayed_work; struct batadv_priv *bat_priv;
- delayed_work = container_of(work, struct delayed_work, work); + delayed_work = to_delayed_work(work); bat_priv = container_of(delayed_work, struct batadv_priv, orig_work); _batadv_purge_orig(bat_priv); queue_delayed_work(batadv_event_workqueue,