Skip to content

Commit 5ba7dcf

Browse files
ecsvsimonwunderlich
authored andcommitted
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: 0ede9f4 ("batman-adv: protect bit operations to count OGMs with spinlock") Signed-off-by: Sven Eckelmann <[email protected]> Signed-off-by: Simon Wunderlich <[email protected]>
1 parent 974a6b2 commit 5ba7dcf

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

net/batman-adv/bat_iv_ogm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,7 +1214,7 @@ static bool batadv_iv_ogm_calc_tq(struct batadv_orig_node *orig_node,
12141214
orig_node->last_seen = jiffies;
12151215

12161216
/* 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);
12181218
if_num = if_incoming->if_num;
12191219
orig_eq_count = orig_neigh_node->bat_iv.bcast_own_sum[if_num];
12201220
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,
12241224
} else {
12251225
neigh_rq_count = 0;
12261226
}
1227-
spin_unlock_bh(&orig_node->bat_iv.ogm_cnt_lock);
1227+
spin_unlock_bh(&orig_neigh_node->bat_iv.ogm_cnt_lock);
12281228

12291229
/* pay attention to not get a value bigger than 100 % */
12301230
if (orig_eq_count > neigh_rq_count)

0 commit comments

Comments
 (0)