Audio: SRC: Add safeguard against missing, wrong size or type init data

In some error situations the configuration init_data may be NULL, and
in such a situations we should fail gracefully and not crash. Also adds
check that the IPC message is of correct type and for IPC3 only that it
is of correct type.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
This commit is contained in:
Jyri Sarha 2023-06-19 00:16:16 +03:00 committed by Kai Vehmanen
parent 17cb6d9e3a
commit 681135cda9
1 changed files with 12 additions and 0 deletions

View File

@ -920,6 +920,18 @@ static int src_init(struct processing_module *mod)
struct comp_data *cd = NULL;
comp_dbg(dev, "src_init()");
#if CONFIG_IPC_MAJOR_3
if (dev->ipc_config.type != SOF_COMP_SRC) {
comp_err(dev, "src_init(): Wrong IPC config type %u",
dev->ipc_config.type);
return -EINVAL;
}
#endif
if (!cfg->init_data || cfg->size != sizeof(cd->ipc_config)) {
comp_err(dev, "src_init(): Missing or bad size (%u) init data",
cfg->size);
return -EINVAL;
}
/* validate init data - either SRC sink or source rate must be set */
if (src_rate_check(cfg->init_data) < 0) {