Skip to content

Commit 4f2c965

Browse files
abonislawskikv2019i
authored andcommitted
audio: dai: add NULL converter guard in IPC4 playback fanout
Add an if (converter) check around the IPC4 playback multi-sink fanout loop in dai_dma_cb(), mirroring the existing guard already present in the capture branch. The defensive guard ensures consistent NULL handling and prevents a potential NULL pointer dereference if the code path is ever exercised directly. Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
1 parent c351193 commit 4f2c965

1 file changed

Lines changed: 27 additions & 23 deletions

File tree

src/audio/dai-zephyr.c

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -310,37 +310,41 @@ dai_dma_cb(struct dai_data *dd, struct comp_dev *dev, uint32_t bytes,
310310
/*
311311
* copy from local buffer to all sinks that are not gateway buffers
312312
* using the right PCM converter function.
313+
* Skip in case of endpoint DAI devices created by the copier.
313314
*/
314-
struct comp_buffer *sink;
315+
if (converter) {
316+
struct comp_buffer *sink;
315317

316-
comp_dev_for_each_consumer(dev, sink) {
317-
struct comp_dev *sink_dev;
318-
int j;
318+
comp_dev_for_each_consumer(dev, sink) {
319+
struct comp_dev *sink_dev;
320+
int j;
319321

320-
if (sink == dd->dma_buffer)
321-
continue;
322+
if (sink == dd->dma_buffer)
323+
continue;
322324

323-
sink_dev = comp_buffer_get_sink_component(sink);
325+
sink_dev = comp_buffer_get_sink_component(sink);
324326

325-
j = IPC4_SRC_QUEUE_ID(buf_get_id(sink));
327+
j = IPC4_SRC_QUEUE_ID(buf_get_id(sink));
326328

327-
if (j >= IPC4_COPIER_MODULE_OUTPUT_PINS_COUNT) {
328-
comp_err(dev, "Sink queue ID: %d >= max output pin count: %d\n",
329-
j, IPC4_COPIER_MODULE_OUTPUT_PINS_COUNT);
330-
ret = -EINVAL;
331-
continue;
332-
}
329+
if (j >= IPC4_COPIER_MODULE_OUTPUT_PINS_COUNT) {
330+
comp_err(dev, "Sink queue ID: %d >= max output pin count: %d\n",
331+
j, IPC4_COPIER_MODULE_OUTPUT_PINS_COUNT);
332+
ret = -EINVAL;
333+
continue;
334+
}
333335

334-
if (!converter[j]) {
335-
comp_err(dev, "No PCM converter for sink queue %d\n", j);
336-
ret = -EINVAL;
337-
continue;
338-
}
336+
if (!converter[j]) {
337+
comp_err(dev, "No PCM converter for sink queue %d\n", j);
338+
ret = -EINVAL;
339+
continue;
340+
}
339341

340-
if (sink_dev && sink_dev->state == COMP_STATE_ACTIVE &&
341-
audio_buffer_hw_params_configured(&sink->audio_buffer)) {
342-
ret = stream_copy_from_no_consume(dev, dd->local_buffer, sink,
343-
converter[j], bytes, dd->chmap);
342+
if (sink_dev && sink_dev->state == COMP_STATE_ACTIVE &&
343+
audio_buffer_hw_params_configured(&sink->audio_buffer)) {
344+
ret = stream_copy_from_no_consume(dev, dd->local_buffer,
345+
sink, converter[j],
346+
bytes, dd->chmap);
347+
}
344348
}
345349
}
346350
#endif

0 commit comments

Comments
 (0)