Skip to contentSkip to conversation

ath5k: fix an off by one check in ath5k_eeprom_read_freq_list()

PATCH In review Dan Carpenter 3 participants 4 messages Feb 6, 2023 – Feb 22, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ath5k: fix an off by one check in ath5k_eeprom_read_freq_list()

This loop checks that i < max at the start of loop but then it does i++ which could put it past the end of the array. It's harmless to check again and prevent a potential out of bounds.

Fixes 1048643ea94d ("ath5k: Clean up eeprom parsing and add missing calibration data")

---

 drivers/net/wireless/ath/ath5k/eeprom.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath5k/eeprom.c +1 -1
index d444b3d70ba2..58d3e86f6256 100644
@@ -529,7 +529,7 @@ ath5k_eeprom_read_freq_list(struct ath5k_hw *ah, int *offset, int max,
 		ee->ee_n_piers[mode]++;
 
 		freq2 = (val >> 8) & 0xff;
-		if (!freq2)
+		if (!freq2 || i >= max)
 			break;
 
 		pc[i++].freq = ath5k_eeprom_bin2freq(ee,
Signature · 1 line
2.35.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Dan Carpenter

This loop checks that i < max at the start of loop but then it does i++ which could put it past the end of the array. It's harmless to check again and prevent a potential out of bounds.

Fixes 1048643ea94d ("ath5k: Clean up eeprom parsing and add missing calibration data")

Luis

maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Dan Carpenter
Quoted 6 lines · Dan Carpenter

This loop checks that i < max at the start of loop but then it does i++ which could put it past the end of the array. It's harmless to check again and prevent a potential out of bounds.

Fixes 1048643ea94d ("ath5k: Clean up eeprom parsing and add missing calibration data")

Luis

#3 lore raw
In reply to Dan Carpenter
Quoted 8 lines · Dan Carpenter

This loop checks that i < max at the start of loop but then it does i++ which could put it past the end of the array. It's harmless to check again and prevent a potential out of bounds.

Fixes 1048643ea94d ("ath5k: Clean up eeprom parsing and add missing calibration data")

Patch applied to ath-next branch of ath.git, thanks.

4c856ee12df8 wifi: ath5k: fix an off by one check in ath5k_eeprom_read_freq_list()

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/Y+D9hPQrHfWBJhXz@kili/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches