Linux wireless drivers development
 help / color / mirror / Atom feed
* [PATCH] ath5k: fix an off by one check in ath5k_eeprom_read_freq_list()
@ 2023-02-06 13:15 Dan Carpenter
  2023-02-06 14:54 ` Luis Chamberlain
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Dan Carpenter @ 2023-02-06 13:15 UTC (permalink / raw)
  To: Jiri Slaby, Felix Fietkau
  Cc: Nick Kossifidis, Luis Chamberlain, Kalle Valo, John W. Linville,
	linux-wireless, kernel-janitors

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")
Signed-off-by: Dan Carpenter <error27@gmail.com>
---

 drivers/net/wireless/ath/ath5k/eeprom.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath5k/eeprom.c b/drivers/net/wireless/ath/ath5k/eeprom.c
index d444b3d70ba2..58d3e86f6256 100644
--- a/drivers/net/wireless/ath/ath5k/eeprom.c
+++ b/drivers/net/wireless/ath/ath5k/eeprom.c
@@ -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,
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ath5k: fix an off by one check in ath5k_eeprom_read_freq_list()
  2023-02-06 13:15 [PATCH] ath5k: fix an off by one check in ath5k_eeprom_read_freq_list() Dan Carpenter
@ 2023-02-06 14:54 ` Luis Chamberlain
  2023-02-21 22:01 ` Luis Chamberlain
  2023-02-22  9:56 ` Kalle Valo
  2 siblings, 0 replies; 4+ messages in thread
From: Luis Chamberlain @ 2023-02-06 14:54 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Jiri Slaby, Felix Fietkau, Nick Kossifidis, Kalle Valo,
	John W. Linville, linux-wireless, kernel-janitors

On Mon, Feb 06, 2023 at 04:15:48PM +0300, Dan Carpenter wrote:
> 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")
> Signed-off-by: Dan Carpenter <error27@gmail.com>

Reviewed-by:  Luis Chamberlain <mcgrof@kernel.org>

  Luis

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ath5k: fix an off by one check in ath5k_eeprom_read_freq_list()
  2023-02-06 13:15 [PATCH] ath5k: fix an off by one check in ath5k_eeprom_read_freq_list() Dan Carpenter
  2023-02-06 14:54 ` Luis Chamberlain
@ 2023-02-21 22:01 ` Luis Chamberlain
  2023-02-22  9:56 ` Kalle Valo
  2 siblings, 0 replies; 4+ messages in thread
From: Luis Chamberlain @ 2023-02-21 22:01 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Jiri Slaby, Felix Fietkau, Nick Kossifidis, Kalle Valo,
	John W. Linville, linux-wireless, kernel-janitors

On Mon, Feb 06, 2023 at 04:15:48PM +0300, Dan Carpenter wrote:
> 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")
> Signed-off-by: Dan Carpenter <error27@gmail.com>

Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>

 Luis

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ath5k: fix an off by one check in ath5k_eeprom_read_freq_list()
  2023-02-06 13:15 [PATCH] ath5k: fix an off by one check in ath5k_eeprom_read_freq_list() Dan Carpenter
  2023-02-06 14:54 ` Luis Chamberlain
  2023-02-21 22:01 ` Luis Chamberlain
@ 2023-02-22  9:56 ` Kalle Valo
  2 siblings, 0 replies; 4+ messages in thread
From: Kalle Valo @ 2023-02-22  9:56 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Jiri Slaby, Felix Fietkau, Nick Kossifidis, Luis Chamberlain,
	John W. Linville, linux-wireless, kernel-janitors

Dan Carpenter <error27@gmail.com> wrote:

> 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")
> Signed-off-by: Dan Carpenter <error27@gmail.com>
> Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
> Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>

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()

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

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-02-22  9:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-06 13:15 [PATCH] ath5k: fix an off by one check in ath5k_eeprom_read_freq_list() Dan Carpenter
2023-02-06 14:54 ` Luis Chamberlain
2023-02-21 22:01 ` Luis Chamberlain
2023-02-22  9:56 ` Kalle Valo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox