* [PATCH] mt76: mt7615: fix possible division by 0 in mt7615_mac_update_mib_stats
@ 2020-04-06 21:56 Lorenzo Bianconi
0 siblings, 0 replies; only message in thread
From: Lorenzo Bianconi @ 2020-04-06 21:56 UTC (permalink / raw)
To: nbd; +Cc: lorenzo.bianconi, ryder.lee, linux-wireless
Check that val is not zero before aggr_per estimation in order to avoid a
possible division by 0
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
drivers/net/wireless/mediatek/mt76/mt7615/mac.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
index 596fa17a58ff..23f905dfecc7 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
@@ -1702,9 +1702,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++) {
--
2.25.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2020-04-06 21:56 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-06 21:56 [PATCH] mt76: mt7615: fix possible division by 0 in mt7615_mac_update_mib_stats Lorenzo Bianconi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).