diff --git a/src/ipc/ipc4/helper.c b/src/ipc/ipc4/helper.c index 5881fbbfb0b5..d341200a2d2b 100644 --- a/src/ipc/ipc4/helper.c +++ b/src/ipc/ipc4/helper.c @@ -145,6 +145,23 @@ __cold struct comp_dev *comp_new_ipc4(struct ipc4_module_init_instance *module_i ipc_config.ipc_config_size); return NULL; } + + /* + * The parent pipeline referenced by ppl_instance_id must already exist. + * IPC4 requires the host to create the pipeline (SOF_IPC4_GLB_CREATE_PIPELINE) + * before instantiating any module inside it. Validate the reference here, at + * the common creation entry point, before allocating the component. This + * guarantees the "a live IPC4 component always belongs to a live pipeline" + * invariant for every driver, so no module init path (e.g. the copier writing + * pipeline->source_comp / pipeline->sink_comp) can dereference a NULL + * dev->pipeline. + */ + if (!ipc_get_comp_by_ppl_id(ipc_get(), COMP_TYPE_PIPELINE, ipc_config.pipeline_id, + IPC_COMP_IGNORE_REMOTE)) { + tr_err(&ipc_tr, "comp 0x%x: parent pipeline %u does not exist", comp_id, + (uint32_t)ipc_config.pipeline_id); + return NULL; + } #ifdef CONFIG_DCACHE_LINE_SIZE if (!IS_ENABLED(CONFIG_LIBRARY)) sys_cache_data_invd_range((__sparse_force void __sparse_cache *)