ath9k: dfs: Remove VLA usage
Subsystems (3)
PATCH v3 1/1 ath9k: dfs: Remove VLA usage
In the quest to remove all stack VLA usage from the kernel[1], this redefines FFT_NUM_SAMPLES as a #define instead of const int, which still triggers gcc's VLA checking pass.
[1] https://lkml.org/lkml/2018/3/7/621
---
v3: replace FFT_NUM_SAMPLES as a #define (Joe)
--- drivers/net/wireless/ath/ath9k/dfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath9k/dfs.c +2 -2
@@ -40,8 +40,8 @@ static const int BIN_DELTA_MIN = 1;static const int BIN_DELTA_MAX =10 ;/* we need at least 3 deltas / 4 samples for a reliable chirp detection */ -#define NUM_DIFFS 3 -static const int FFT_NUM_SAMPLES = (NUM_DIFFS +1 ); +#define NUM_DIFFS 3 +#define FFT_NUM_SAMPLES (NUM_DIFFS + 1)/* Threshold for difference of delta peaks */ static const int MAX_DIFF =2 ;
Signature · 6 lines
2.7.4 -- Kees Cook Pixel Security
Quoted 20 lines · Kees Cook
In the quest to remove all stack VLA usage from the kernel[1], this redefines
FFT_NUM_SAMPLESas a #define instead of const int, which still triggers gcc's VLA checking pass.[1] https://lkml.org/lkml/2018/3/7/621
Co-developed-by Andreas Christoforou <[email protected]>Signed-off-by Kees Cook <[email protected]>---
v3: replaceFFT_NUM_SAMPLESas a #define (Joe)--- drivers/net/wireless/ath/ath9k/dfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/net/wireless/ath/ath9k/dfs.c +0
-0
drivers/net/wireless/ath/ath9k/dfs.c static const int BIN_DELTA_MIN = 1; · line 44
Quoted 7 lines
drivers/net/wireless/ath/ath9k/dfs.c +2
-2@@ -40,8 +40,8 @@ static const int BIN_DELTA_MIN = 1;static const int BIN_DELTA_MAX =10 ;/* we need at least 3 deltas / 4 samples for a reliable chirp detection */ -#define NUM_DIFFS 3 -static const int FFT_NUM_SAMPLES = (NUM_DIFFS +1 ); +#define NUM_DIFFS 3 +#define FFT_NUM_SAMPLES (NUM_DIFFS + 1)
I have already applied an almost identical patch:
ath9k: dfs: remove accidental use of stack VLA
Signature · 1 line
Kalle Valo
Quoted 5 lines · Kalle Valo
I have already applied an almost identical patch:
ath9k: dfs: remove accidental use of stack VLA
Ah! Cool, no worries. I didn't see that in linux-next yet. :)
Thanks!
-Kees
Signature · 2 lines
Kees Cook Pixel Security