Skip to content

Commit cb3de87

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 size and of correct type. Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
1 parent c069197 commit cb3de87

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/audio/src/src.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -987,6 +987,12 @@ static int src_init(struct processing_module *mod)
987987

988988
comp_dbg(dev, "src_init()");
989989

990+
if (dev->ipc_config.type != SOF_COMP_SRC || !cfg->init_data ||
991+
cfg->size != sizeof(cd->ipc_config)) {
992+
comp_err(dev, "src_init(): Missing or bad size (%u) init data",
993+
cfg->size);
994+
return -EINVAL;
995+
}
990996
/* validate init data - either SRC sink or source rate must be set */
991997
if (src_rate_check(cfg->init_data) < 0) {
992998
comp_err(dev, "src_init(): SRC sink and source rate are not set");

0 commit comments

Comments
 (0)