From 17ff0269d3aba89641ee819ccd217401be3c267d Mon Sep 17 00:00:00 2001 From: Shrushti P K Date: Sun, 15 Nov 2026 16:31:41 +0530 Subject: [PATCH] probe: fix unsigned dma_request_channel() error check 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. --- src/kernel/probe/probe.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/kernel/probe/probe.c b/src/kernel/probe/probe.c index 434317ffe093..165402a3df40 100644 --- a/src/kernel/probe/probe.c +++ b/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) return err; - channel = dma_request_channel(dma->dc.dmac->z_dev, &channel); - if (channel < 0) { + err = dma_request_channel(dma->dc.dmac->z_dev, &channel); + if (err < 0) { tr_err(&pr_tr, "dma_request_channel() failed"); return -EINVAL; } - dma->dc.chan = &dma->dc.dmac->chan[channel]; + dma->dc.chan = &dma->dc.dmac->chan[err]; /* initialize dma buffer */ err = probe_dma_buffer_init(&dma->dmapb, PROBE_BUFFER_LOCAL_SIZE, addr_align);