Skip to content

Commit d065d54

Browse files
wjablon1lgirdwood
authored andcommitted
module-adapter: Add NULL check for sink buffer
Return error if a sink buffer is not present before it is accessed while calculating period size in module_adapter_prepare. This might occur when a pipeline is built incorrectly (without binding) and the sink buffer is not connected to a module. Signed-off-by: Wojciech Jablonski <wojciech.jablonski@intel.com>
1 parent 4f4b8cf commit d065d54

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/audio/module_adapter/module_adapter.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,10 +460,15 @@ int module_adapter_prepare(struct comp_dev *dev)
460460

461461
mod->deep_buff_bytes = 0;
462462

463-
/* Get period_bytes first on prepare(). At this point it is guaranteed that the stream
464-
* parameter from sink buffer is settled, and still prior to all references to period_bytes.
463+
/* Get period_bytes first on prepare(). At this point the stream parameter from sink buffer
464+
* shall be settled, provided that the pipeline is built correctly (bind IPC received).
465+
* Hence check for NULL.
465466
*/
466467
sink = comp_dev_get_first_data_consumer(dev);
468+
if (!sink) {
469+
comp_err(dev, "no sink present on period size calculation");
470+
return -EINVAL;
471+
}
467472

468473
mod->period_bytes = audio_stream_period_bytes(&sink->stream, dev->frames);
469474
comp_dbg(dev, "got period_bytes = %u", mod->period_bytes);

0 commit comments

Comments
 (0)