It is hard to understand why the refcnt is increased when it isn't done near the actual place the new reference is used. So using kref_get right before the place which requires the reference and in the same function helps to avoid accidental problems causedy incorrect reference counting.
Signed-off-by: Sven Eckelmann sven@narfation.org --- v2: - split patch based on type
net/batman-adv/originator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c index 3940b5d..d778eb1 100644 --- a/net/batman-adv/originator.c +++ b/net/batman-adv/originator.c @@ -127,9 +127,9 @@ batadv_orig_node_vlan_new(struct batadv_orig_node *orig_node, goto out;
kref_init(&vlan->refcount); - kref_get(&vlan->refcount); vlan->vid = vid;
+ kref_get(&vlan->refcount); hlist_add_head_rcu(&vlan->list, &orig_node->vlan_list);
out:
It is hard to understand why the refcnt is increased when it isn't done near the actual place the new reference is used. So using kref_get right before the place which requires the reference and in the same function helps to avoid accidental problems causedy incorrect reference counting.
Signed-off-by: Sven Eckelmann sven@narfation.org --- v2: - split patch based on type
net/batman-adv/originator.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c index d778eb1..1db577d 100644 --- a/net/batman-adv/originator.c +++ b/net/batman-adv/originator.c @@ -380,6 +380,7 @@ batadv_orig_ifinfo_new(struct batadv_orig_node *orig_node, orig_ifinfo->if_outgoing = if_outgoing; INIT_HLIST_NODE(&orig_ifinfo->list); kref_init(&orig_ifinfo->refcount); + kref_get(&orig_ifinfo->refcount); hlist_add_head_rcu(&orig_ifinfo->list, &orig_node->ifinfo_list);
On Friday, July 15, 2016 17:39:17 Sven Eckelmann wrote:
It is hard to understand why the refcnt is increased when it isn't done near the actual place the new reference is used. So using kref_get right before the place which requires the reference and in the same function helps to avoid accidental problems causedy incorrect reference counting.
Signed-off-by: Sven Eckelmann sven@narfation.org
v2:
- split patch based on type
net/batman-adv/originator.c | 1 + 1 file changed, 1 insertion(+)
Applied in revision 180df6d.
Thanks, Marek
It is hard to understand why the refcnt is increased when it isn't done near the actual place the new reference is used. So using kref_get right before the place which requires the reference and in the same function helps to avoid accidental problems causedy incorrect reference counting.
Signed-off-by: Sven Eckelmann sven@narfation.org --- v2: - split patch based on type
net/batman-adv/translation-table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index af2bfef..89d7b1d 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -1402,9 +1402,9 @@ batadv_tt_global_orig_entry_add(struct batadv_tt_global_entry *tt_global, orig_entry->orig_node = orig_node; orig_entry->ttvn = ttvn; kref_init(&orig_entry->refcount); - kref_get(&orig_entry->refcount);
spin_lock_bh(&tt_global->list_lock); + kref_get(&orig_entry->refcount); hlist_add_head_rcu(&orig_entry->list, &tt_global->orig_list); spin_unlock_bh(&tt_global->list_lock);
On Friday, July 15, 2016 17:39:18 Sven Eckelmann wrote:
It is hard to understand why the refcnt is increased when it isn't done near the actual place the new reference is used. So using kref_get right before the place which requires the reference and in the same function helps to avoid accidental problems causedy incorrect reference counting.
Signed-off-by: Sven Eckelmann sven@narfation.org
v2:
- split patch based on type
net/batman-adv/translation-table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied in revision 6d4b516.
Thanks, Marek
It is hard to understand why the refcnt is increased when it isn't done near the actual place the new reference is used. So using kref_get right before the place which requires the reference and in the same function helps to avoid accidental problems causedy incorrect reference counting.
Signed-off-by: Sven Eckelmann sven@narfation.org --- v2: - split patch based on type
net/batman-adv/originator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c index 1db577d..1de583d 100644 --- a/net/batman-adv/originator.c +++ b/net/batman-adv/originator.c @@ -454,9 +454,9 @@ batadv_neigh_ifinfo_new(struct batadv_neigh_node *neigh,
INIT_HLIST_NODE(&neigh_ifinfo->list); kref_init(&neigh_ifinfo->refcount); - kref_get(&neigh_ifinfo->refcount); neigh_ifinfo->if_outgoing = if_outgoing;
+ kref_get(&neigh_ifinfo->refcount); hlist_add_head_rcu(&neigh_ifinfo->list, &neigh->ifinfo_list);
out:
On Friday, July 15, 2016 17:39:19 Sven Eckelmann wrote:
It is hard to understand why the refcnt is increased when it isn't done near the actual place the new reference is used. So using kref_get right before the place which requires the reference and in the same function helps to avoid accidental problems causedy incorrect reference counting.
Signed-off-by: Sven Eckelmann sven@narfation.org
v2:
- split patch based on type
net/batman-adv/originator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied in revision ecd3e3d.
Thanks, Marek
It is hard to understand why the refcnt is increased when it isn't done near the actual place the new reference is used. So using kref_get right before the place which requires the reference and in the same function helps to avoid accidental problems causedy incorrect reference counting.
Signed-off-by: Sven Eckelmann sven@narfation.org --- v2: - split patch based on type
net/batman-adv/originator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c index 1de583d..3bf3065 100644 --- a/net/batman-adv/originator.c +++ b/net/batman-adv/originator.c @@ -648,8 +648,8 @@ batadv_neigh_node_create(struct batadv_orig_node *orig_node,
/* extra reference for return */ kref_init(&neigh_node->refcount); - kref_get(&neigh_node->refcount);
+ kref_get(&neigh_node->refcount); hlist_add_head_rcu(&neigh_node->list, &orig_node->neigh_list);
batadv_dbg(BATADV_DBG_BATMAN, orig_node->bat_priv,
On Friday, July 15, 2016 17:39:20 Sven Eckelmann wrote:
It is hard to understand why the refcnt is increased when it isn't done near the actual place the new reference is used. So using kref_get right before the place which requires the reference and in the same function helps to avoid accidental problems causedy incorrect reference counting.
Signed-off-by: Sven Eckelmann sven@narfation.org
v2:
- split patch based on type
net/batman-adv/originator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied in revision 9904e1b.
Thanks, Marek
It is hard to understand why the refcnt is increased when it isn't done near the actual place the new reference is used. So using kref_get right before the place which requires the reference and in the same function helps to avoid accidental problems causedy incorrect reference counting.
Signed-off-by: Sven Eckelmann sven@narfation.org --- v2: - split patch based on type
net/batman-adv/bat_iv_ogm.c | 7 ++++--- net/batman-adv/bat_v_ogm.c | 5 ++--- net/batman-adv/gateway_client.c | 2 +- net/batman-adv/network-coding.c | 7 +++---- net/batman-adv/originator.c | 1 - 5 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c index a40cdf2..4e84dbc 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c @@ -319,17 +319,18 @@ batadv_iv_ogm_orig_get(struct batadv_priv *bat_priv, const u8 *addr) if (!orig_node->bat_iv.bcast_own_sum) goto free_orig_node;
+ kref_get(&orig_node->refcount); hash_added = batadv_hash_add(bat_priv->orig_hash, batadv_compare_orig, batadv_choose_orig, orig_node, &orig_node->hash_entry); if (hash_added != 0) - goto free_orig_node; + goto free_orig_node_hash;
return orig_node;
-free_orig_node: - /* free twice, as batadv_orig_node_new sets refcount to 2 */ +free_orig_node_hash: batadv_orig_node_put(orig_node); +free_orig_node: batadv_orig_node_put(orig_node);
return NULL; diff --git a/net/batman-adv/bat_v_ogm.c b/net/batman-adv/bat_v_ogm.c index 6fbba4e..1aeeadc 100644 --- a/net/batman-adv/bat_v_ogm.c +++ b/net/batman-adv/bat_v_ogm.c @@ -73,13 +73,12 @@ struct batadv_orig_node *batadv_v_ogm_orig_get(struct batadv_priv *bat_priv, if (!orig_node) return NULL;
+ kref_get(&orig_node->refcount); hash_added = batadv_hash_add(bat_priv->orig_hash, batadv_compare_orig, batadv_choose_orig, orig_node, &orig_node->hash_entry); if (hash_added != 0) { - /* orig_node->refcounter is initialised to 2 by - * batadv_orig_node_new() - */ + /* remove refcnt for newly created orig_node and hash entry */ batadv_orig_node_put(orig_node); batadv_orig_node_put(orig_node); orig_node = NULL; diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c index a77a179..94f8f9d 100644 --- a/net/batman-adv/gateway_client.c +++ b/net/batman-adv/gateway_client.c @@ -333,8 +333,8 @@ static void batadv_gw_node_add(struct batadv_priv *bat_priv, if (!gw_node) return;
- kref_get(&orig_node->refcount); INIT_HLIST_NODE(&gw_node->list); + kref_get(&orig_node->refcount); gw_node->orig_node = orig_node; gw_node->bandwidth_down = ntohl(gateway->bandwidth_down); gw_node->bandwidth_up = ntohl(gateway->bandwidth_up); diff --git a/net/batman-adv/network-coding.c b/net/batman-adv/network-coding.c index 293ef4f..3814cfb 100644 --- a/net/batman-adv/network-coding.c +++ b/net/batman-adv/network-coding.c @@ -856,14 +856,13 @@ batadv_nc_get_nc_node(struct batadv_priv *bat_priv, if (!nc_node) return NULL;
- kref_get(&orig_neigh_node->refcount); - /* Initialize nc_node */ INIT_LIST_HEAD(&nc_node->list); - ether_addr_copy(nc_node->addr, orig_node->orig); - nc_node->orig_node = orig_neigh_node; kref_init(&nc_node->refcount); kref_get(&nc_node->refcount); + ether_addr_copy(nc_node->addr, orig_node->orig); + kref_get(&orig_neigh_node->refcount); + nc_node->orig_node = orig_neigh_node;
/* Select ingoing or outgoing coding node */ if (in_coding) { diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c index 3bf3065..8208276 100644 --- a/net/batman-adv/originator.c +++ b/net/batman-adv/originator.c @@ -906,7 +906,6 @@ struct batadv_orig_node *batadv_orig_node_new(struct batadv_priv *bat_priv,
/* extra reference for return */ kref_init(&orig_node->refcount); - kref_get(&orig_node->refcount);
orig_node->bat_priv = bat_priv; ether_addr_copy(orig_node->orig, addr);
On Friday, July 15, 2016 17:39:21 Sven Eckelmann wrote:
It is hard to understand why the refcnt is increased when it isn't done near the actual place the new reference is used. So using kref_get right before the place which requires the reference and in the same function helps to avoid accidental problems causedy incorrect reference counting.
Signed-off-by: Sven Eckelmann sven@narfation.org
v2:
- split patch based on type
net/batman-adv/bat_iv_ogm.c | 7 ++++--- net/batman-adv/bat_v_ogm.c | 5 ++--- net/batman-adv/gateway_client.c | 2 +- net/batman-adv/network-coding.c | 7 +++---- net/batman-adv/originator.c | 1 - 5 files changed, 10 insertions(+), 12 deletions(-)
Applied in revision de6330c.
Thanks, Marek
It is hard to understand why the refcnt is increased when it isn't done near the actual place the new reference is used. So using kref_get right before the place which requires the reference and in the same function helps to avoid accidental problems causedy incorrect reference counting.
Signed-off-by: Sven Eckelmann sven@narfation.org --- v2: - split patch based on type
net/batman-adv/translation-table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index 89d7b1d..d21b65c 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -727,7 +727,6 @@ bool batadv_tt_local_add(struct net_device *soft_iface, const u8 *addr, if (batadv_is_wifi_netdev(in_dev)) tt_local->common.flags |= BATADV_TT_CLIENT_WIFI; kref_init(&tt_local->common.refcount); - kref_get(&tt_local->common.refcount); tt_local->last_seen = jiffies; tt_local->common.added_at = tt_local->last_seen; tt_local->vlan = vlan; @@ -739,6 +738,7 @@ bool batadv_tt_local_add(struct net_device *soft_iface, const u8 *addr, is_multicast_ether_addr(addr)) tt_local->common.flags |= BATADV_TT_CLIENT_NOPURGE;
+ kref_get(&tt_local->common.refcount); hash_added = batadv_hash_add(bat_priv->tt.local_hash, batadv_compare_tt, batadv_choose_tt, &tt_local->common, &tt_local->common.hash_entry);
On Friday, July 15, 2016 17:39:22 Sven Eckelmann wrote:
It is hard to understand why the refcnt is increased when it isn't done near the actual place the new reference is used. So using kref_get right before the place which requires the reference and in the same function helps to avoid accidental problems causedy incorrect reference counting.
Signed-off-by: Sven Eckelmann sven@narfation.org
v2:
- split patch based on type
net/batman-adv/translation-table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied in revision af05c2a.
Thanks, Marek
It is hard to understand why the refcnt is increased when it isn't done near the actual place the new reference is used. So using kref_get right before the place which requires the reference and in the same function helps to avoid accidental problems causedy incorrect reference counting.
Signed-off-by: Sven Eckelmann sven@narfation.org --- v2: - split patch based on type
net/batman-adv/translation-table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index d21b65c..a9d2283 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -1480,13 +1480,13 @@ static bool batadv_tt_global_add(struct batadv_priv *bat_priv, if (flags & BATADV_TT_CLIENT_ROAM) tt_global_entry->roam_at = jiffies; kref_init(&common->refcount); - kref_get(&common->refcount); common->added_at = jiffies;
INIT_HLIST_HEAD(&tt_global_entry->orig_list); atomic_set(&tt_global_entry->orig_list_count, 0); spin_lock_init(&tt_global_entry->list_lock);
+ kref_get(&common->refcount); hash_added = batadv_hash_add(bat_priv->tt.global_hash, batadv_compare_tt, batadv_choose_tt, common,
On Friday, July 15, 2016 17:39:23 Sven Eckelmann wrote:
It is hard to understand why the refcnt is increased when it isn't done near the actual place the new reference is used. So using kref_get right before the place which requires the reference and in the same function helps to avoid accidental problems causedy incorrect reference counting.
Signed-off-by: Sven Eckelmann sven@narfation.org
v2:
- split patch based on type
net/batman-adv/translation-table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied in revision 3cf4d0b.
Thanks, Marek
It is hard to understand why the refcnt is increased when it isn't done near the actual place the new reference is used. So using kref_get right before the place which requires the reference and in the same function helps to avoid accidental problems causedy incorrect reference counting.
Signed-off-by: Sven Eckelmann sven@narfation.org --- v2: - split patch based on type
net/batman-adv/bridge_loop_avoidance.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c index c75ef64..21bc3d0 100644 --- a/net/batman-adv/bridge_loop_avoidance.c +++ b/net/batman-adv/bridge_loop_avoidance.c @@ -711,12 +711,13 @@ static void batadv_bla_add_claim(struct batadv_priv *bat_priv, claim->lasttime = jiffies; kref_get(&backbone_gw->refcount); claim->backbone_gw = backbone_gw; - kref_init(&claim->refcount); - kref_get(&claim->refcount); + batadv_dbg(BATADV_DBG_BLA, bat_priv, "bla_add_claim(): adding new entry %pM, vid %d to hash ...\n", mac, BATADV_PRINT_VID(vid)); + + kref_get(&claim->refcount); hash_added = batadv_hash_add(bat_priv->bla.claim_hash, batadv_compare_claim, batadv_choose_claim, claim,
On Friday, July 15, 2016 17:39:24 Sven Eckelmann wrote:
It is hard to understand why the refcnt is increased when it isn't done near the actual place the new reference is used. So using kref_get right before the place which requires the reference and in the same function helps to avoid accidental problems causedy incorrect reference counting.
Signed-off-by: Sven Eckelmann sven@narfation.org
v2:
- split patch based on type
net/batman-adv/bridge_loop_avoidance.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Applied in revision 7b229c7.
Thanks, Marek
It is hard to understand why the refcnt is increased when it isn't done near the actual place the new reference is used. So using kref_get right before the place which requires the reference and in the same function helps to avoid accidental problems causedy incorrect reference counting.
Signed-off-by: Sven Eckelmann sven@narfation.org --- v2: - split patch based on type
net/batman-adv/bridge_loop_avoidance.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c index 21bc3d0..0035b8f 100644 --- a/net/batman-adv/bridge_loop_avoidance.c +++ b/net/batman-adv/bridge_loop_avoidance.c @@ -519,11 +519,9 @@ batadv_bla_get_backbone_gw(struct batadv_priv *bat_priv, u8 *orig, atomic_set(&entry->wait_periods, 0); ether_addr_copy(entry->orig, orig); INIT_WORK(&entry->report_work, batadv_bla_loopdetect_report); - - /* one for the hash, one for returning */ kref_init(&entry->refcount); - kref_get(&entry->refcount);
+ kref_get(&entry->refcount); hash_added = batadv_hash_add(bat_priv->bla.backbone_hash, batadv_compare_backbone_gw, batadv_choose_backbone_gw, entry,
On Friday, July 15, 2016 17:39:25 Sven Eckelmann wrote:
It is hard to understand why the refcnt is increased when it isn't done near the actual place the new reference is used. So using kref_get right before the place which requires the reference and in the same function helps to avoid accidental problems causedy incorrect reference counting.
Signed-off-by: Sven Eckelmann sven@narfation.org
v2:
- split patch based on type
net/batman-adv/bridge_loop_avoidance.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
Applied in revision c7cdcc9.
Thanks, Marek
It is hard to understand why the refcnt is increased when it isn't done near the actual place the new reference is used. So using kref_get right before the place which requires the reference and in the same function helps to avoid accidental problems causedy incorrect reference counting.
Signed-off-by: Sven Eckelmann sven@narfation.org --- v2: - split patch based on type
net/batman-adv/distributed-arp-table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c index b1cc8bf..059bc23 100644 --- a/net/batman-adv/distributed-arp-table.c +++ b/net/batman-adv/distributed-arp-table.c @@ -343,8 +343,8 @@ static void batadv_dat_entry_add(struct batadv_priv *bat_priv, __be32 ip, ether_addr_copy(dat_entry->mac_addr, mac_addr); dat_entry->last_update = jiffies; kref_init(&dat_entry->refcount); - kref_get(&dat_entry->refcount);
+ kref_get(&dat_entry->refcount); hash_added = batadv_hash_add(bat_priv->dat.hash, batadv_compare_dat, batadv_hash_dat, dat_entry, &dat_entry->hash_entry);
On Friday, July 15, 2016 17:39:26 Sven Eckelmann wrote:
It is hard to understand why the refcnt is increased when it isn't done near the actual place the new reference is used. So using kref_get right before the place which requires the reference and in the same function helps to avoid accidental problems causedy incorrect reference counting.
Signed-off-by: Sven Eckelmann sven@narfation.org
v2:
- split patch based on type
net/batman-adv/distributed-arp-table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied in revision 22f8257.
Thanks, Marek
It is hard to understand why the refcnt is increased when it isn't done near the actual place the new reference is used. So using kref_get right before the place which requires the reference and in the same function helps to avoid accidental problems causedy incorrect reference counting.
Signed-off-by: Sven Eckelmann sven@narfation.org --- v2: - split patch based on type
net/batman-adv/gateway_client.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c index 94f8f9d..afa43d4 100644 --- a/net/batman-adv/gateway_client.c +++ b/net/batman-adv/gateway_client.c @@ -333,14 +333,15 @@ static void batadv_gw_node_add(struct batadv_priv *bat_priv, if (!gw_node) return;
+ kref_init(&gw_node->refcount); INIT_HLIST_NODE(&gw_node->list); kref_get(&orig_node->refcount); gw_node->orig_node = orig_node; gw_node->bandwidth_down = ntohl(gateway->bandwidth_down); gw_node->bandwidth_up = ntohl(gateway->bandwidth_up); - kref_init(&gw_node->refcount);
spin_lock_bh(&bat_priv->gw.list_lock); + kref_get(&gw_node->refcount); hlist_add_head_rcu(&gw_node->list, &bat_priv->gw.list); spin_unlock_bh(&bat_priv->gw.list_lock);
@@ -351,6 +352,9 @@ static void batadv_gw_node_add(struct batadv_priv *bat_priv, ntohl(gateway->bandwidth_down) % 10, ntohl(gateway->bandwidth_up) / 10, ntohl(gateway->bandwidth_up) % 10); + + /* don't return reference to new gw_node */ + batadv_gw_node_put(gw_node); }
/**
On Friday, July 15, 2016 17:39:27 Sven Eckelmann wrote:
It is hard to understand why the refcnt is increased when it isn't done near the actual place the new reference is used. So using kref_get right before the place which requires the reference and in the same function helps to avoid accidental problems causedy incorrect reference counting.
Signed-off-by: Sven Eckelmann sven@narfation.org
v2:
- split patch based on type
net/batman-adv/gateway_client.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
Applied in revision b7981d4.
Thanks, Marek
It is hard to understand why the refcnt is increased when it isn't done near the actual place the new reference is used. So using kref_get right before the place which requires the reference and in the same function helps to avoid accidental problems causedy incorrect reference counting.
Signed-off-by: Sven Eckelmann sven@narfation.org --- v2: - split patch based on type
net/batman-adv/hard-interface.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index 714af8e..adb0377 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c @@ -658,6 +658,7 @@ batadv_hardif_add_interface(struct net_device *net_dev) INIT_HLIST_HEAD(&hard_iface->neigh_list);
spin_lock_init(&hard_iface->neigh_list_lock); + kref_init(&hard_iface->refcount);
hard_iface->num_bcasts = BATADV_NUM_BCASTS_DEFAULT; if (batadv_is_wifi_netdev(net_dev)) @@ -665,11 +666,8 @@ batadv_hardif_add_interface(struct net_device *net_dev)
batadv_v_hardif_init(hard_iface);
- /* extra reference for return */ - kref_init(&hard_iface->refcount); - kref_get(&hard_iface->refcount); - batadv_check_known_mac_addr(hard_iface->net_dev); + kref_get(&hard_iface->refcount); list_add_tail_rcu(&hard_iface->list, &batadv_hardif_list);
return hard_iface;
On Friday, July 15, 2016 17:39:28 Sven Eckelmann wrote:
It is hard to understand why the refcnt is increased when it isn't done near the actual place the new reference is used. So using kref_get right before the place which requires the reference and in the same function helps to avoid accidental problems causedy incorrect reference counting.
Signed-off-by: Sven Eckelmann sven@narfation.org
v2:
- split patch based on type
net/batman-adv/hard-interface.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
Applied in revision a1ca984.
Thanks, Marek
It is hard to understand why the refcnt is increased when it isn't done near the actual place the new reference is used. So using kref_get right before the place which requires the reference and in the same function helps to avoid accidental problems causedy incorrect reference counting.
Signed-off-by: Sven Eckelmann sven@narfation.org --- v2: - split patch based on type
net/batman-adv/soft-interface.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c index e508bf5..49e16b6 100644 --- a/net/batman-adv/soft-interface.c +++ b/net/batman-adv/soft-interface.c @@ -594,6 +594,7 @@ int batadv_softif_create_vlan(struct batadv_priv *bat_priv, unsigned short vid) }
spin_lock_bh(&bat_priv->softif_vlan_list_lock); + kref_get(&vlan->refcount); hlist_add_head_rcu(&vlan->list, &bat_priv->softif_vlan_list); spin_unlock_bh(&bat_priv->softif_vlan_list_lock);
@@ -604,6 +605,9 @@ int batadv_softif_create_vlan(struct batadv_priv *bat_priv, unsigned short vid) bat_priv->soft_iface->dev_addr, vid, BATADV_NULL_IFINDEX, BATADV_NO_MARK);
+ /* don't return reference to new softif_vlan */ + batadv_softif_vlan_put(vlan); + return 0; }
On Friday, July 15, 2016 17:39:29 Sven Eckelmann wrote:
It is hard to understand why the refcnt is increased when it isn't done near the actual place the new reference is used. So using kref_get right before the place which requires the reference and in the same function helps to avoid accidental problems causedy incorrect reference counting.
Signed-off-by: Sven Eckelmann sven@narfation.org
v2:
- split patch based on type
net/batman-adv/soft-interface.c | 4 ++++ 1 file changed, 4 insertions(+)
Applied in revision 67694d5.
Thanks, Marek
It is hard to understand why the refcnt is increased when it isn't done near the actual place the new reference is used. So using kref_get right before the place which requires the reference and in the same function helps to avoid accidental problems causedy incorrect reference counting.
Signed-off-by: Sven Eckelmann sven@narfation.org --- v2: - split patch based on type
net/batman-adv/network-coding.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/batman-adv/network-coding.c b/net/batman-adv/network-coding.c index 3814cfb..4f4cfe5 100644 --- a/net/batman-adv/network-coding.c +++ b/net/batman-adv/network-coding.c @@ -859,7 +859,6 @@ batadv_nc_get_nc_node(struct batadv_priv *bat_priv, /* Initialize nc_node */ INIT_LIST_HEAD(&nc_node->list); kref_init(&nc_node->refcount); - kref_get(&nc_node->refcount); ether_addr_copy(nc_node->addr, orig_node->orig); kref_get(&orig_neigh_node->refcount); nc_node->orig_node = orig_neigh_node; @@ -878,6 +877,7 @@ batadv_nc_get_nc_node(struct batadv_priv *bat_priv,
/* Add nc_node to orig_node */ spin_lock_bh(lock); + kref_get(&nc_node->refcount); list_add_tail_rcu(&nc_node->list, list); spin_unlock_bh(lock);
On Friday, July 15, 2016 17:39:30 Sven Eckelmann wrote:
It is hard to understand why the refcnt is increased when it isn't done near the actual place the new reference is used. So using kref_get right before the place which requires the reference and in the same function helps to avoid accidental problems causedy incorrect reference counting.
Signed-off-by: Sven Eckelmann sven@narfation.org
v2:
- split patch based on type
net/batman-adv/network-coding.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied in revision 9ba0625.
Thanks, Marek
It is hard to understand why the refcnt is increased when it isn't done near the actual place the new reference is used. So using kref_get right before the place which requires the reference and in the same function helps to avoid accidental problems causedy incorrect reference counting.
Signed-off-by: Sven Eckelmann sven@narfation.org --- v2: - split patch based on type
net/batman-adv/network-coding.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/batman-adv/network-coding.c b/net/batman-adv/network-coding.c index 4f4cfe5..165cd27 100644 --- a/net/batman-adv/network-coding.c +++ b/net/batman-adv/network-coding.c @@ -978,7 +978,6 @@ static struct batadv_nc_path *batadv_nc_get_path(struct batadv_priv *bat_priv, INIT_LIST_HEAD(&nc_path->packet_list); spin_lock_init(&nc_path->packet_list_lock); kref_init(&nc_path->refcount); - kref_get(&nc_path->refcount); nc_path->last_valid = jiffies; ether_addr_copy(nc_path->next_hop, dst); ether_addr_copy(nc_path->prev_hop, src); @@ -988,6 +987,7 @@ static struct batadv_nc_path *batadv_nc_get_path(struct batadv_priv *bat_priv, nc_path->next_hop);
/* Add nc_path to hash table */ + kref_get(&nc_path->refcount); hash_added = batadv_hash_add(hash, batadv_nc_hash_compare, batadv_nc_hash_choose, &nc_path_key, &nc_path->hash_entry);
On Friday, July 15, 2016 17:39:31 Sven Eckelmann wrote:
It is hard to understand why the refcnt is increased when it isn't done near the actual place the new reference is used. So using kref_get right before the place which requires the reference and in the same function helps to avoid accidental problems causedy incorrect reference counting.
Signed-off-by: Sven Eckelmann sven@narfation.org
v2:
- split patch based on type
net/batman-adv/network-coding.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied in revision 8427a98.
Thanks, Marek
It is hard to understand why the refcnt is increased when it isn't done near the actual place the new reference is used. So using kref_get right before the place which requires the reference and in the same function helps to avoid accidental problems causedy incorrect reference counting.
Signed-off-by: Sven Eckelmann sven@narfation.org --- v2: - split patch based on type
net/batman-adv/tvlv.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/net/batman-adv/tvlv.c b/net/batman-adv/tvlv.c index 3d1cf0f..3533867 100644 --- a/net/batman-adv/tvlv.c +++ b/net/batman-adv/tvlv.c @@ -257,8 +257,13 @@ void batadv_tvlv_container_register(struct batadv_priv *bat_priv, spin_lock_bh(&bat_priv->tvlv.container_list_lock); tvlv_old = batadv_tvlv_container_get(bat_priv, type, version); batadv_tvlv_container_remove(bat_priv, tvlv_old); + + kref_get(&tvlv_new->refcount); hlist_add_head(&tvlv_new->list, &bat_priv->tvlv.container_list); spin_unlock_bh(&bat_priv->tvlv.container_list_lock); + + /* don't return reference to new tvlv_container */ + batadv_tvlv_container_put(tvlv_new); }
/**
On Friday, July 15, 2016 17:39:32 Sven Eckelmann wrote:
It is hard to understand why the refcnt is increased when it isn't done near the actual place the new reference is used. So using kref_get right before the place which requires the reference and in the same function helps to avoid accidental problems causedy incorrect reference counting.
Signed-off-by: Sven Eckelmann sven@narfation.org
v2:
- split patch based on type
net/batman-adv/tvlv.c | 5 +++++ 1 file changed, 5 insertions(+)
Applied in revision aebb6e7.
Thanks, Marek
It is hard to understand why the refcnt is increased when it isn't done near the actual place the new reference is used. So using kref_get right before the place which requires the reference and in the same function helps to avoid accidental problems causedy incorrect reference counting.
Signed-off-by: Sven Eckelmann sven@narfation.org --- v2: - split patch based on type
net/batman-adv/tvlv.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/net/batman-adv/tvlv.c b/net/batman-adv/tvlv.c index 3533867..77654f0 100644 --- a/net/batman-adv/tvlv.c +++ b/net/batman-adv/tvlv.c @@ -547,8 +547,12 @@ void batadv_tvlv_handler_register(struct batadv_priv *bat_priv, INIT_HLIST_NODE(&tvlv_handler->list);
spin_lock_bh(&bat_priv->tvlv.handler_list_lock); + kref_get(&tvlv_handler->refcount); hlist_add_head_rcu(&tvlv_handler->list, &bat_priv->tvlv.handler_list); spin_unlock_bh(&bat_priv->tvlv.handler_list_lock); + + /* don't return reference to new tvlv_handler */ + batadv_tvlv_handler_put(tvlv_handler); }
/**
On Freitag, 15. Juli 2016 17:39:33 CEST Sven Eckelmann wrote:
It is hard to understand why the refcnt is increased when it isn't done near the actual place the new reference is used. So using kref_get right before the place which requires the reference and in the same function helps to avoid accidental problems causedy incorrect reference counting.
Signed-off-by: Sven Eckelmann sven@narfation.org
v2:
- split patch based on type
s/tvlv_container/tvlv_handler/ in subject.
Kind regards, Sven
On Friday, July 15, 2016 17:39:33 Sven Eckelmann wrote:
It is hard to understand why the refcnt is increased when it isn't done near the actual place the new reference is used. So using kref_get right before the place which requires the reference and in the same function helps to avoid accidental problems causedy incorrect reference counting.
Signed-off-by: Sven Eckelmann sven@narfation.org
v2:
- split patch based on type
net/batman-adv/tvlv.c | 4 ++++ 1 file changed, 4 insertions(+)
Applied in revision 95136e0.
Thanks, Marek
On Friday, July 15, 2016 17:39:16 Sven Eckelmann wrote:
It is hard to understand why the refcnt is increased when it isn't done near the actual place the new reference is used. So using kref_get right before the place which requires the reference and in the same function helps to avoid accidental problems causedy incorrect reference counting.
Signed-off-by: Sven Eckelmann sven@narfation.org
v2:
- split patch based on type
net/batman-adv/originator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied in revision 333d1de.
Thanks, Marek
b.a.t.m.a.n@lists.open-mesh.org