rtwn: remove out-of-bounds access + fix debug output.

Omit unused rates while initializing / dumping Tx power values.

They were not accessed anywhere (except for debugging), so this is
(mostly) no-op.

Tested with
 * RTL8188EU, STA mode.
 * RTL8812AU, STA mode.

Found by:	PVS-Studio
This commit is contained in:
avos 2017-04-12 07:21:54 +00:00
parent 29c5f354fe
commit b14b54982c
3 changed files with 6 additions and 6 deletions

View File

@ -110,7 +110,7 @@ r88e_get_txpower(struct rtwn_softc *sc, int chain,
for (ridx = RTWN_RIDX_CCK1; ridx <= RTWN_RIDX_CCK11; ridx++)
power[ridx] = base->pwr[0][ridx];
}
for (ridx = RTWN_RIDX_OFDM6; ridx < RTWN_RIDX_COUNT; ridx++) {
for (ridx = RTWN_RIDX_OFDM6; ridx <= max_mcs; ridx++) {
if (rs->regulatory == 3)
power[ridx] = base->pwr[0][ridx];
else if (rs->regulatory == 1) {

View File

@ -229,13 +229,13 @@ r92c_set_txpower(struct rtwn_softc *sc, struct ieee80211_channel *c)
rtwn_r92c_get_txpower(sc, i, c, power);
#ifdef RTWN_DEBUG
if (sc->sc_debug & RTWN_DEBUG_TXPWR) {
int ridx;
int max_mcs, ridx;
max_mcs = RTWN_RIDX_MCS(sc->ntxchains * 8 - 1);
/* Dump per-rate Tx power values. */
printf("Tx power for chain %d:\n", i);
for (ridx = RTWN_RIDX_CCK1;
ridx < RTWN_RIDX_COUNT;
ridx++)
for (ridx = RTWN_RIDX_CCK1; ridx <= max_mcs; ridx++)
printf("Rate %d = %u\n", ridx, power[ridx]);
}
#endif

View File

@ -247,7 +247,7 @@ r12a_get_txpower(struct rtwn_softc *sc, int chain,
if (sc->sc_debug & RTWN_DEBUG_TXPWR) {
/* Dump per-rate Tx power values. */
printf("Tx power for chain %d:\n", chain);
for (ridx = RTWN_RIDX_CCK1; ridx < RTWN_RIDX_COUNT; ridx++)
for (ridx = RTWN_RIDX_CCK1; ridx <= max_mcs; ridx++)
printf("Rate %d = %u\n", ridx, power[ridx]);
}
#endif