Commit 77b74952 authored by Nikita Zhandarovich's avatar Nikita Zhandarovich Committed by Felix Fietkau
Browse files

wifi: mt76: mt7915: fix possible integer overflows in mt7915_muru_stats_show()



Assuming sums of values stored in variables such as sub_total_cnt
and total_ppdu_cnt are big enough to warrant their u64 type, it
makes sense to ensure that their calculation takes into account
possible integer overflow issues.

Play it safe and fix the problem by casting right hand expressions
to u64 as well. Also, slightly adjust tabulation.

Found by Linux Verification Center (linuxtesting.org) with static
analysis tool SVACE.

Fixes: 1966a507 ("mt76: mt7915: add mu-mimo and ofdma debugfs knobs")
Signed-off-by: default avatarNikita Zhandarovich <n.zhandarovich@fintech.ru>
Link: https://patch.msgid.link/20250114154441.16920-1-n.zhandarovich@fintech.ru


Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 2d5630b0
Loading
Loading
Loading
Loading
+23 −22
Original line number Diff line number Diff line
@@ -303,7 +303,7 @@ static int mt7915_muru_stats_show(struct seq_file *file, void *data)
		   phy->mib.dl_vht_3mu_cnt,
		   phy->mib.dl_vht_4mu_cnt);

	sub_total_cnt = phy->mib.dl_vht_2mu_cnt +
	sub_total_cnt = (u64)phy->mib.dl_vht_2mu_cnt +
			     phy->mib.dl_vht_3mu_cnt +
			     phy->mib.dl_vht_4mu_cnt;

@@ -353,7 +353,7 @@ static int mt7915_muru_stats_show(struct seq_file *file, void *data)
		   phy->mib.dl_he_9to16ru_cnt,
		   phy->mib.dl_he_gtr16ru_cnt);

	sub_total_cnt = phy->mib.dl_he_2mu_cnt +
	sub_total_cnt = (u64)phy->mib.dl_he_2mu_cnt +
			     phy->mib.dl_he_3mu_cnt +
			     phy->mib.dl_he_4mu_cnt;
	total_ppdu_cnt = sub_total_cnt;
@@ -361,7 +361,7 @@ static int mt7915_muru_stats_show(struct seq_file *file, void *data)
	seq_printf(file, "\nTotal HE MU-MIMO DL PPDU count: %lld",
		   sub_total_cnt);

	sub_total_cnt = phy->mib.dl_he_2ru_cnt +
	sub_total_cnt = (u64)phy->mib.dl_he_2ru_cnt +
			     phy->mib.dl_he_3ru_cnt +
			     phy->mib.dl_he_4ru_cnt +
			     phy->mib.dl_he_5to8ru_cnt +
@@ -372,7 +372,8 @@ static int mt7915_muru_stats_show(struct seq_file *file, void *data)
	seq_printf(file, "\nTotal HE OFDMA DL PPDU count: %lld",
		   sub_total_cnt);

	total_ppdu_cnt += phy->mib.dl_he_su_cnt + phy->mib.dl_he_ext_su_cnt;
	total_ppdu_cnt += (u64)phy->mib.dl_he_su_cnt +
			       phy->mib.dl_he_ext_su_cnt;

	seq_printf(file, "\nAll HE DL PPDU count: %lld", total_ppdu_cnt);

@@ -404,7 +405,7 @@ static int mt7915_muru_stats_show(struct seq_file *file, void *data)
		   phy->mib.ul_hetrig_9to16ru_cnt,
		   phy->mib.ul_hetrig_gtr16ru_cnt);

	sub_total_cnt = phy->mib.ul_hetrig_2mu_cnt +
	sub_total_cnt = (u64)phy->mib.ul_hetrig_2mu_cnt +
			     phy->mib.ul_hetrig_3mu_cnt +
			     phy->mib.ul_hetrig_4mu_cnt;
	total_ppdu_cnt = sub_total_cnt;
@@ -412,7 +413,7 @@ static int mt7915_muru_stats_show(struct seq_file *file, void *data)
	seq_printf(file, "\nTotal HE MU-MIMO UL TB PPDU count: %lld",
		   sub_total_cnt);

	sub_total_cnt = phy->mib.ul_hetrig_2ru_cnt +
	sub_total_cnt = (u64)phy->mib.ul_hetrig_2ru_cnt +
			     phy->mib.ul_hetrig_3ru_cnt +
			     phy->mib.ul_hetrig_4ru_cnt +
			     phy->mib.ul_hetrig_5to8ru_cnt +