math: auditory: guard mod_psy_get_mel_filterbank() against zero divisors#10916
Open
singalsu wants to merge 1 commit into
Open
math: auditory: guard mod_psy_get_mel_filterbank() against zero divisors#10916singalsu wants to merge 1 commit into
singalsu wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds explicit validation in mod_psy_get_mel_filterbank() to prevent division-by-zero/invalid range calculations under unusual mel filterbank configurations.
Changes:
- Reject non-positive
mel_stepconfigurations before using it as a divisor. - Reject Slaney-normalization bins where
right_hz <= left_hzbefore computing the scale factor.
4f88f36 to
fe2026c
Compare
Comment on lines
173
to
175
| for (i = 0; i < fb->mel_bins; i++) { | ||
| left_mel = mel_start + i * mel_step; | ||
| center_mel = mel_start + (i + 1) * mel_step; |
Collaborator
Author
There was a problem hiding this comment.
Won't do, not relevant.
fe2026c to
a9ff7ee
Compare
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>
a9ff7ee to
dbdd503
Compare
Collaborator
Author
|
The quickbuild fails 1) for MTL Test HDA passthrough compress data 2) PTL HDA link random DMA are not related to this change. |
lyakh
approved these changes
Jun 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.