summaryrefslogtreecommitdiffstats
path: root/net/batman-adv/bridge_loop_avoidance.c
diff options
context:
space:
mode:
authorSven Eckelmann <sven@narfation.org>2016-01-16 10:29:44 +0100
committerAntonio Quartulli <a@unstable.cc>2016-02-10 23:24:00 +0800
commit71b7e3d3161f7b1922a2c3b5d39b7b451c3f8cf7 (patch)
tree11ac892fc1457ec31eafe3d370a8214be85a95c7 /net/batman-adv/bridge_loop_avoidance.c
parent06e56ded867d1035b877aba28189736f41e85ab0 (diff)
downloadlinux-stable-71b7e3d3161f7b1922a2c3b5d39b7b451c3f8cf7.tar.gz
linux-stable-71b7e3d3161f7b1922a2c3b5d39b7b451c3f8cf7.tar.bz2
linux-stable-71b7e3d3161f7b1922a2c3b5d39b7b451c3f8cf7.zip
batman-adv: Convert batadv_bla_claim to kref
batman-adv uses a self-written reference implementation which is just based on atomic_t. This is less obvious when reading the code than kref and therefore increases the change that the reference counting will be missed. Signed-off-by: Sven Eckelmann <sven@narfation.org> Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch> Signed-off-by: Antonio Quartulli <a@unstable.cc>
Diffstat (limited to 'net/batman-adv/bridge_loop_avoidance.c')
-rw-r--r--net/batman-adv/bridge_loop_avoidance.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
index 41116e4c2e34..7781f39c174d 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -174,8 +174,12 @@ batadv_backbone_gw_free_ref(struct batadv_bla_backbone_gw *backbone_gw)
* grace period
* @ref: kref pointer of the claim
*/
-static void batadv_claim_release(struct batadv_bla_claim *claim)
+static void batadv_claim_release(struct kref *ref)
{
+ struct batadv_bla_claim *claim;
+
+ claim = container_of(ref, struct batadv_bla_claim, refcount);
+
batadv_backbone_gw_free_ref(claim->backbone_gw);
kfree_rcu(claim, rcu);
}
@@ -187,8 +191,7 @@ static void batadv_claim_release(struct batadv_bla_claim *claim)
*/
static void batadv_claim_free_ref(struct batadv_bla_claim *claim)
{
- if (atomic_dec_and_test(&claim->refcount))
- batadv_claim_release(claim);
+ kref_put(&claim->refcount, batadv_claim_release);
}
/**
@@ -219,7 +222,7 @@ static struct batadv_bla_claim
if (!batadv_compare_claim(&claim->hash_entry, data))
continue;
- if (!atomic_inc_not_zero(&claim->refcount))
+ if (!kref_get_unless_zero(&claim->refcount))
continue;
claim_tmp = claim;
@@ -651,7 +654,8 @@ static void batadv_bla_add_claim(struct batadv_priv *bat_priv,
claim->lasttime = jiffies;
claim->backbone_gw = backbone_gw;
- atomic_set(&claim->refcount, 2);
+ 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));