math: fft: move NULL guard before plan dereferences in HiFi3 variants#10781
Merged
Conversation
In fft_execute_16() and fft_execute_32() HiFi3 implementations, local variables are initialized from plan->size, plan->len (and in 32-bit: plan->inb32, plan->outb32, plan->bit_reverse_idx) before the 'if (!plan)' guard is reached. Move all plan-> accesses after the NULL check, matching the generic fft_16.c / fft_32.c ordering. Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes potential NULL pointer dereferences in HiFi3 FFT implementations by moving plan-> member accesses to occur after the if (!plan) NULL check, aligning with the ordering used in the generic fft_16.c/fft_32.c.
Changes:
- In
fft_execute_16(), defer initialization ofsizeandlenuntil after the NULL guard. - In
fft_execute_32(), defer initialization ofinx,outx,idx,size, andlenuntil after the NULL and pointer-field guards.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/math/fft/fft_16_hifi3.c | Moves plan->size/plan->len reads after the !plan check. |
| src/math/fft/fft_32_hifi3.c | Moves all plan-> member reads after the !plan and pointer checks. |
lyakh
approved these changes
May 15, 2026
lgirdwood
approved these changes
May 15, 2026
| if (!plan->inb32 || !plan->outb32) | ||
| return; | ||
|
|
||
| inx = (ae_int32x2 *)plan->inb32; |
Member
There was a problem hiding this comment.
@singalsu do we also check if these are vector aligned somewhere ?
tmleman
approved these changes
May 15, 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.
In fft_execute_16() and fft_execute_32() HiFi3 implementations, local variables are initialized from plan->size, plan->len (and in 32-bit: plan->inb32, plan->outb32, plan->bit_reverse_idx) before the 'if (!plan)' guard is reached. Move all plan-> accesses after the NULL check, matching the generic fft_16.c / fft_32.c ordering.