Skip to content

Commit

Permalink
kernel/ath: Limit check index variables before using them.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sascha Wildner committed Nov 28, 2016
1 parent 35f7426 commit 93d7266
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion sys/contrib/dev/ath/ath_hal/ar9300/ar9300_reset.c
Expand Up @@ -1081,7 +1081,7 @@ ar9300_spur_mitigate_ofdm(struct ath_hal *ah, struct ieee80211_channel *chan)
OS_REG_RMW_FIELD(ah, AR_PHY_SPUR_REG, AR_PHY_SPUR_REG_MASK_RATE_CNTL, 0);

i = 0;
while (spur_chans_ptr[i] && i < 5) {
while (i < 5 && spur_chans_ptr[i]) {
freq_offset = FBIN2FREQ(spur_chans_ptr[i], mode) - synth_freq;
if (abs(freq_offset) < range) {
/*
Expand Down
2 changes: 1 addition & 1 deletion sys/dev/netif/ath/ath_hal/ah_eeprom_v14.c
Expand Up @@ -285,7 +285,7 @@ v14EepromReadCTLInfo(struct ath_hal *ah, HAL_EEPROM_v14 *ee)

HALASSERT(AR5416_NUM_CTLS <= sizeof(ee->ee_rdEdgesPower)/NUM_EDGES);

for (i = 0; ee->ee_base.ctlIndex[i] != 0 && i < AR5416_NUM_CTLS; i++) {
for (i = 0; i < AR5416_NUM_CTLS && ee->ee_base.ctlIndex[i] != 0; i++) {
for (j = 0; j < NUM_EDGES; j ++) {
/* XXX Confirm this is the right thing to do when an invalid channel is stored */
if (ee->ee_base.ctlData[i].ctlEdges[CTL_CHAIN][j].bChannel == AR5416_BCHAN_UNUSED) {
Expand Down
2 changes: 1 addition & 1 deletion sys/dev/netif/ath/ath_hal/ar5212/ar5112.c
Expand Up @@ -617,7 +617,7 @@ getFullPwrTable(uint16_t numPcdacs, uint16_t *pcdacs, int16_t *power, int16_t ma
return AH_FALSE;
}
for (ii = 0; ii < 64; ii++) {
if (ii>pcdacs[idxR] && idxR < numPcdacs-1) {
if (idxR < numPcdacs-1 && ii>pcdacs[idxR]) {
idxL++;
idxR++;
}
Expand Down
4 changes: 2 additions & 2 deletions sys/dev/netif/ath/ath_hal/ar9002/ar9280_olc.c
Expand Up @@ -84,8 +84,8 @@ ar9280olcGetTxGainIndex(struct ath_hal *ah,
*pwr = (rawDatasetOpLoop[idxL].pwrPdg[0][0] +
rawDatasetOpLoop[idxR].pwrPdg[0][0])/2;
}
while (pcdac > AH9280(ah)->originalGain[i] &&
i < (AR9280_TX_GAIN_TABLE_SIZE - 1))
while (i < (AR9280_TX_GAIN_TABLE_SIZE - 1) &&
pcdac > AH9280(ah)->originalGain[i])
i++;

*pcdacIdx = i;
Expand Down

0 comments on commit 93d7266

Please sign in to comment.