Skip to content

math: fft: move NULL guard before plan dereferences in HiFi3 variants#10781

Merged
lgirdwood merged 1 commit into
thesofproject:mainfrom
abonislawski:fix/fft-hifi3-null
May 15, 2026
Merged

math: fft: move NULL guard before plan dereferences in HiFi3 variants#10781
lgirdwood merged 1 commit into
thesofproject:mainfrom
abonislawski:fix/fft-hifi3-null

Conversation

@abonislawski
Copy link
Copy Markdown
Member

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.

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>
Copilot AI review requested due to automatic review settings May 15, 2026 09:26
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 of size and len until after the NULL guard.
  • In fft_execute_32(), defer initialization of inx, outx, idx, size, and len until 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.

@abonislawski abonislawski requested a review from singalsu May 15, 2026 09:30
if (!plan->inb32 || !plan->outb32)
return;

inx = (ae_int32x2 *)plan->inb32;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@singalsu do we also check if these are vector aligned somewhere ?

@lgirdwood lgirdwood merged commit 5494188 into thesofproject:main May 15, 2026
47 of 48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants