Skip to content

Commit c78efeb

Browse files
author
Jyri Sarha
committed
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 c069197 commit c78efeb

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
@@ -986,6 +986,18 @@ static int src_init(struct processing_module *mod)
986986
struct comp_data *cd = NULL;
987987

988988
comp_dbg(dev, "src_init()");
989+
#if CONFIG_IPC_MAJOR_3
990+
if (dev->ipc_config.type != SOF_COMP_SRC) {
991+
comp_err(dev, "src_init(): Wrong IPC config type %u",
992+
dev->ipc_config.type);
993+
return -EINVAL;
994+
}
995+
#endif
996+
if (!cfg->init_data || cfg->size != sizeof(cd->ipc_config)) {
997+
comp_err(dev, "src_init(): Missing or bad size (%u) init data",
998+
cfg->size);
999+
return -EINVAL;
1000+
}
9891001

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

0 commit comments

Comments
 (0)