Skip to content

Commit

Permalink
Audio: Module adapter: Fix in IPC4 invalid blob pass to init()
Browse files Browse the repository at this point in the history
The cfg->size is the size of ipc4_base_module_cfg. The
cfg->data is NULL but when such is encountered the
comp_init_data_blob() allocates a zero bytes of size.

Such blob is illegal and e.g. IIR will fail if not another
blob is received by prepare(). DC block operates,
but applies a rather high cut-off frequency that results
to silent audio for e.g. lower voice frequencies. What
happens with such illegal blob is component specific.

The expected operation for most components is pass-through
when a configuration blob is not set. This change should
ensure that the component is not initialized with incorrect
bytes control data if such is not passed with topology.

IPC4 SRC utilizes in init() an ipc4_base_module_cfg variant
that adds an uint32_t after it for sink rate. To pass the check
for cfg->size the size subtract done in module adapter need to
be taken into account.

TODO: There is similar size check in selector, need to make similar
change there.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
  • Loading branch information
singalsu committed Sep 24, 2024
1 parent f2efd4a commit 7839da7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/audio/module_adapter/module_adapter_ipc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ int module_adapter_init_data(struct comp_dev *dev,
return -EINVAL;

dst->base_cfg = cfg->base_cfg;
dst->size = cfgsz;
#if CONFIG_LIBRARY
dst->size = cfgsz - sizeof(struct ipc4_base_module_cfg_with_uuid);
#else
dst->size = cfgsz - sizeof(cfg->base_cfg);
#endif

if (cfgsz >= sizeof(*cfg)) {
int n_in = cfg->base_cfg_ext.nb_input_pins;
Expand Down
4 changes: 3 additions & 1 deletion src/audio/src/src_ipc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,12 @@ int src_init(struct processing_module *mod)
struct module_config *cfg = &md->cfg;
struct comp_dev *dev = mod->dev;
struct comp_data *cd = NULL;
const size_t cfg_size_expect = sizeof(cd->ipc_config) -
sizeof(struct ipc4_base_module_cfg);

comp_dbg(dev, "src_init()");

if (!cfg->init_data || cfg->size != sizeof(cd->ipc_config)) {
if (!cfg->init_data || cfg->size != cfg_size_expect) {
comp_err(dev, "src_init(): Missing or bad size (%u) init data",
cfg->size);
return -EINVAL;
Expand Down

0 comments on commit 7839da7

Please sign in to comment.