Skip to content

Commit

Permalink
wifi: mt76: mt76x0: fix oob access in mt76x0_phy_get_target_power
Browse files Browse the repository at this point in the history
After 'commit ba45841ca5eb ("wifi: mt76: mt76x02: simplify struct
mt76x02_rate_power")', mt76x02 relies on ht[0-7] rate_power data for
vht mcs{0,7}, while it uses vth[0-1] rate_power for vht mcs {8,9}.
Fix a possible out-of-bound access in mt76x0_phy_get_target_power routine.

Fixes: ba45841ca5eb ("wifi: mt76: mt76x02: simplify struct mt76x02_rate_power")
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
  • Loading branch information
LorenzoBianconi authored and nbd168 committed Dec 10, 2022
1 parent 5185bba commit eeb6949
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion mt76x0/phy.c
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,12 @@ mt76x0_phy_get_target_power(struct mt76x02_dev *dev, u8 tx_mode,
if (tx_rate > 9)
return -EINVAL;

*target_power = cur_power + dev->rate_power.vht[tx_rate];
*target_power = cur_power;
if (tx_rate > 7)
*target_power += dev->rate_power.vht[tx_rate - 8];
else
*target_power += dev->rate_power.ht[tx_rate];

*target_pa_power = mt76x0_phy_get_rf_pa_mode(dev, 1, tx_rate);
break;
default:
Expand Down

0 comments on commit eeb6949

Please sign in to comment.