diff --git a/src/audio/module_adapter/module/volume/volume.c b/src/audio/module_adapter/module/volume/volume.c index 509ab7de0c26..486d68a8572b 100644 --- a/src/audio/module_adapter/module/volume/volume.c +++ b/src/audio/module_adapter/module/volume/volume.c @@ -1671,7 +1671,7 @@ static struct module_interface gain_interface = { .free = volume_free }; -DECLARE_MODULE_ADAPTER(gain_interface, gain_uuid, gain_tr); +DECLARE_MODULE_ADAPTER_WITH_TYPE(gain_interface, gain_uuid, gain_tr, SOF_COMP_VOLUME); SOF_MODULE_INIT(gain, sys_comp_module_gain_interface_init); #endif #endif diff --git a/src/audio/src/src.c b/src/audio/src/src.c index 31c943d2b059..56827eab63d3 100644 --- a/src/audio/src/src.c +++ b/src/audio/src/src.c @@ -1058,5 +1058,5 @@ static struct module_interface src_interface = { .free = src_free, }; -DECLARE_MODULE_ADAPTER(src_interface, src_uuid, src_tr); +DECLARE_MODULE_ADAPTER_WITH_TYPE(src_interface, src_uuid, src_tr, SOF_COMP_SRC); SOF_MODULE_INIT(src, sys_comp_module_src_interface_init); diff --git a/src/include/sof/audio/module_adapter/module/generic.h b/src/include/sof/audio/module_adapter/module/generic.h index e6d89738e1e6..53b8ac08fd57 100644 --- a/src/include/sof/audio/module_adapter/module/generic.h +++ b/src/include/sof/audio/module_adapter/module/generic.h @@ -33,7 +33,7 @@ (value)); \ } while (0) -#define DECLARE_MODULE_ADAPTER(adapter, uuid, tr) \ +#define DECLARE_MODULE_ADAPTER_WITH_TYPE(adapter, uuid, tr, comp_type) \ static struct comp_dev *module_##adapter##_shim_new(const struct comp_driver *drv, \ const struct comp_ipc_config *config, \ const void *spec) \ @@ -42,7 +42,7 @@ static struct comp_dev *module_##adapter##_shim_new(const struct comp_driver *dr } \ \ static const struct comp_driver comp_##adapter##_module = { \ - .type = SOF_COMP_MODULE_ADAPTER, \ + .type = comp_type, \ .uid = SOF_RT_UUID(uuid), \ .tctx = &(tr), \ .ops = { \ @@ -75,6 +75,9 @@ UT_STATIC void sys_comp_module_##adapter##_init(void) \ \ DECLARE_MODULE(sys_comp_module_##adapter##_init) +#define DECLARE_MODULE_ADAPTER(adapter, uuid, tr) \ + DECLARE_MODULE_ADAPTER_WITH_TYPE(adapter, uuid, tr, SOF_COMP_MODULE_ADAPTER) + /** * \enum module_state * \brief Module-specific states diff --git a/src/ipc/ipc3/helper.c b/src/ipc/ipc3/helper.c index 116571e13318..088679ee3dda 100644 --- a/src/ipc/ipc3/helper.c +++ b/src/ipc/ipc3/helper.c @@ -121,6 +121,11 @@ static const struct comp_driver *get_drv(struct sof_ipc_comp *comp) goto out; } + if (comp->type > SOF_COMP_MODULE_ADAPTER) { + tr_err(&comp_tr, "Bad component type: %d\n", comp->type); + goto out; + } + /* search driver list with UUID */ key = k_spin_lock(&drivers->lock); @@ -134,16 +139,23 @@ static const struct comp_driver *get_drv(struct sof_ipc_comp *comp) } } - if (!drv) + k_spin_unlock(&drivers->lock, key); + + if (!drv) { tr_err(&comp_tr, "get_drv(): the provided UUID (%8x%8x%8x%8x) doesn't match to any driver!", *(uint32_t *)(&comp_ext->uuid[0]), *(uint32_t *)(&comp_ext->uuid[4]), *(uint32_t *)(&comp_ext->uuid[8]), *(uint32_t *)(&comp_ext->uuid[12])); + goto out; + } - k_spin_unlock(&drivers->lock, key); - + if (drv->type != comp->type && drv->type != SOF_COMP_MODULE_ADAPTER) { + tr_err(&comp_tr, "get_drv(): Found %pU driver and IPC type differ %d != %d", + drv->tctx->uuid_p, drv->type, comp->type); + drv = NULL; + } out: if (drv) tr_dbg(&comp_tr, "get_drv(), found driver type %d, uuid %pU",