Commit fe2026c
committed
math: auditory: guard mod_psy_get_mel_filterbank() against zero divisors
The mel-bin loop in mod_psy_get_mel_filterbank() divides by delta_cl and
delta_rc on every FFT bin, and by (right_hz - left_hz) when slaney
normalization is enabled. With unusual configurations these denominators
can become zero or negative — for example when start_freq >= end_freq,
when the requested mel_bins is large enough that integer division
truncates the mel step to zero, or at extreme inputs where psy_mel_to_hz
saturates and right_hz no longer exceeds left_hz.
Reject such configurations explicitly. After computing mel_step, return
-EINVAL if it is not positive, which also covers both delta values
since they equal mel_step. In the slaney_normalize branch, also verify
right_hz > left_hz before computing the scale factor.
Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>1 parent 462cfb5 commit fe2026c
1 file changed
Lines changed: 26 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
151 | 161 | | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
152 | 173 | | |
153 | 174 | | |
154 | 175 | | |
| |||
160 | 181 | | |
161 | 182 | | |
162 | 183 | | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
163 | 189 | | |
164 | 190 | | |
165 | 191 | | |
| |||
0 commit comments