Skip to content

Commit 681135c

Browse files
Jyri Sarhakv2019i
authored andcommitted
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>
1 parent 17cb6d9 commit 681135c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/audio/src/src.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,18 @@ static int src_init(struct processing_module *mod)
920920
struct comp_data *cd = NULL;
921921

922922
comp_dbg(dev, "src_init()");
923+
#if CONFIG_IPC_MAJOR_3
924+
if (dev->ipc_config.type != SOF_COMP_SRC) {
925+
comp_err(dev, "src_init(): Wrong IPC config type %u",
926+
dev->ipc_config.type);
927+
return -EINVAL;
928+
}
929+
#endif
930+
if (!cfg->init_data || cfg->size != sizeof(cd->ipc_config)) {
931+
comp_err(dev, "src_init(): Missing or bad size (%u) init data",
932+
cfg->size);
933+
return -EINVAL;
934+
}
923935

924936
/* validate init data - either SRC sink or source rate must be set */
925937
if (src_rate_check(cfg->init_data) < 0) {

0 commit comments

Comments
 (0)