Commit 1855ad53 authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau

mt76: mt7615: fix possible division by 0 in mt7615_mac_update_mib_stats

Check that val is not zero before aggr_per estimation in order to avoid a
possible division by 0
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 9a865741
......@@ -1773,9 +1773,11 @@ mt7615_mac_update_mib_stats(struct mt7615_phy *phy)
val = mt76_get_field(dev, MT_MIB_SDR14(ext_phy),
MT_MIB_AMPDU_MPDU_COUNT);
val2 = mt76_get_field(dev, MT_MIB_SDR15(ext_phy),
MT_MIB_AMPDU_ACK_COUNT);
mib->aggr_per = 1000 * (val - val2) / val;
if (val) {
val2 = mt76_get_field(dev, MT_MIB_SDR15(ext_phy),
MT_MIB_AMPDU_ACK_COUNT);
mib->aggr_per = 1000 * (val - val2) / val;
}
aggr = ext_phy ? ARRAY_SIZE(dev->mt76.aggr_stats) / 2 : 0;
for (i = 0; i < 4; i++) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment