[PATCH] wifi: mt76: clamp channel power to the s8 range

JB Tsai jb.tsai at mediatek.com
Tue Nov 10 18:27:49 PST 2026


From: "allen.chien" <yung-lun.chien at mediatek.com>

mt76_connac_get_ch_power() computes power as an int from
2 * ch->max_reg_power and then compares it with target_power through
min_t(s8, ...), which truncates the value to 8 bits. An out-of-range
max_reg_power would wrap (e.g. 300 becomes 44) and could lower
target_power wrongly.

Clamp the value into the s8 range when it is calculated. Regulatory
limits are far below that range, so valid input is not affected.

Signed-off-by: allen.chien <yung-lun.chien at mediatek.com>
---
 drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
index ad53bb60d5cd..f5215fa27faf 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
@@ -2168,7 +2168,8 @@ s8 mt76_connac_get_ch_power(struct mt76_phy *phy,
 
 		if (ch->hw_value == chan->hw_value) {
 			if (!(ch->flags & IEEE80211_CHAN_DISABLED)) {
-				int power = 2 * ch->max_reg_power;
+				int power = clamp_t(int, 2 * ch->max_reg_power,
+						    S8_MIN, S8_MAX);
 
 				if (is_mt7663(dev) && (power > 63 || power < -64))
 					power = 63;
-- 
2.45.2




More information about the Linux-mediatek mailing list