diff options
author | Sven Eckelmann <sven@narfation.org> | 2017-12-03 05:26:45 -0500 |
---|---|---|
committer | Simon Wunderlich <sw@simonwunderlich.de> | 2017-12-04 05:47:33 -0500 |
commit | 5ba7dcfe77037b67016263ea597a8b431692ecab (patch) | |
tree | 2a929d165e8dd125005198c17cf9203cb3baffa7 | |
parent | 974a6b20518602310637bd8ac9ad348bf8a864d6 (diff) |
batman-adv: Fix lock for ogm cnt access in batadv_iv_ogm_calc_tq
The originator node object orig_neigh_node is used to when accessing the
bcast_own(_sum) and real_packet_count information. The access to them has
to be protected with the spinlock in orig_neigh_node.
But the function uses the lock in orig_node instead. This is incorrect
because they could be two different originator node objects.
Fixes: 0ede9f41b217 ("batman-adv: protect bit operations to count OGMs with spinlock")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
-rw-r--r-- | net/batman-adv/bat_iv_ogm.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c index 1b659ab652fb..bbe8414b6ee7 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c | |||
@@ -1214,7 +1214,7 @@ static bool batadv_iv_ogm_calc_tq(struct batadv_orig_node *orig_node, | |||
1214 | orig_node->last_seen = jiffies; | 1214 | orig_node->last_seen = jiffies; |
1215 | 1215 | ||
1216 | /* find packet count of corresponding one hop neighbor */ | 1216 | /* find packet count of corresponding one hop neighbor */ |
1217 | spin_lock_bh(&orig_node->bat_iv.ogm_cnt_lock); | 1217 | spin_lock_bh(&orig_neigh_node->bat_iv.ogm_cnt_lock); |
1218 | if_num = if_incoming->if_num; | 1218 | if_num = if_incoming->if_num; |
1219 | orig_eq_count = orig_neigh_node->bat_iv.bcast_own_sum[if_num]; | 1219 | orig_eq_count = orig_neigh_node->bat_iv.bcast_own_sum[if_num]; |
1220 | neigh_ifinfo = batadv_neigh_ifinfo_new(neigh_node, if_outgoing); | 1220 | neigh_ifinfo = batadv_neigh_ifinfo_new(neigh_node, if_outgoing); |
@@ -1224,7 +1224,7 @@ static bool batadv_iv_ogm_calc_tq(struct batadv_orig_node *orig_node, | |||
1224 | } else { | 1224 | } else { |
1225 | neigh_rq_count = 0; | 1225 | neigh_rq_count = 0; |
1226 | } | 1226 | } |
1227 | spin_unlock_bh(&orig_node->bat_iv.ogm_cnt_lock); | 1227 | spin_unlock_bh(&orig_neigh_node->bat_iv.ogm_cnt_lock); |
1228 | 1228 | ||
1229 | /* pay attention to not get a value bigger than 100 % */ | 1229 | /* pay attention to not get a value bigger than 100 % */ |
1230 | if (orig_eq_count > neigh_rq_count) | 1230 | if (orig_eq_count > neigh_rq_count) |