Skip to content

probe: fix unsigned dma_request_channel() error check - #11463

Open
Shrusti-pk wants to merge 1 commit into
thesofproject:mainfrom
Shrusti-pk:probe-dma-chan-signed
Open

Shrusti-pk wants to merge 1 commit into
thesofproject:mainfrom
Shrusti-pk:probe-dma-chan-signed

Conversation

@Shrusti-pk

Copy link
Copy Markdown
Contributor

probe_dma_init() keeps the dma_request_channel() result in a uint32_t, so its "channel < 0" check never fires (clang: -Wtautological-unsigned-zero-compare):

  • trigger: a probe module init payload or INJECTION_DMA_ADD whose node_id v_index does not exist on the host DMA controller (e.g. 0xff) or is already claimed by another stream
  • the -EINVAL is then used as the index, so dc.chan = &chan[0xffffffea], which is 22 entries before the heap allocated chan[] on the 32-bit DSP, and probe_dma_init() returns 0
  • dc.chan->index is read from the neighbouring heap object and handed to dma_config(), dma_start(), dma_reload() and dma_stop(), which only assert on the channel number
  • repro: the verbatim probe_dma_init() body built 32-bit against stubs that follow Zephyr's dma_request_channel() and the ADSP HDA channel filter gives dc.chan = chan[-22] and dma_config() channel 0x5a5a5a5a in both cases; with the fix both return -EINVAL and a free channel still maps to chan[v_index]

Every other dma_request_channel() / sof_dma_request_channel() caller already keeps the result in an int. Not tested on hardware.

probe_dma_init() stores the int returned by dma_request_channel() in
its uint32_t channel variable, so the "channel < 0" check after it can
never be true.

The requested channel is the v_index of the node_id the host passes in
the probe module init payload or in INJECTION_DMA_ADD. When that channel
does not exist on the host DMA controller or is already in use,
dma_request_channel() returns -EINVAL, and the error is used as an index
into dmac->chan[]: on the 32-bit DSP this points 22 entries before the
heap allocated array. probe_dma_init() then reports success, and the
index read from that memory is passed to dma_config(), dma_start(),
dma_reload() and dma_stop(), which only assert on the channel number.

Check the return value in the existing int err and index chan[] with
it, as the other dma_request_channel() callers do.
@sofci

sofci commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

reply test this please to run this test once

@intel-sofci

Copy link
Copy Markdown

PR 11463: test results

Run date: 2026-11-16 12:12 UTC

Tested commit: 17ff0269d3aba89641ee819ccd217401be3c267d

mtl pass rate lnl pass rate ptl pass rate wcl pass rate nvl pass rate

@kv2019i kv2019i left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Code change good but signed-off is missng

Comment thread src/kernel/probe/probe.c
@@ -237,12 +237,12 @@ __cold static int probe_dma_init(struct probe_dma_ext *dma, uint32_t direction)
if (err < 0)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Signed-off missing

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.

4 participants