Skip to content

Commit

Permalink
volume: Bail out if there is no configuration or it is of wrong size
Browse files Browse the repository at this point in the history
It is possible to fabricate a message for FW that initializes volume module
without a configuration. Make a safe guard again crashing from that.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
  • Loading branch information
Jyri Sarha authored and lgirdwood committed Jul 13, 2023
1 parent 385110c commit 7027228
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/audio/module_adapter/module/volume/volume.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,12 @@ static int volume_init(struct processing_module *mod)
const size_t vol_size = sizeof(int32_t) * SOF_IPC_MAX_CHANNELS * 4;
int i;

if (!vol || cfg->size != sizeof(*vol)) {
comp_err(dev, "volume_init(): No configuration data or bad data size %u",
cfg->size);
return -EINVAL;
}

cd = rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM, sizeof(struct vol_data));
if (!cd)
return -ENOMEM;
Expand Down

0 comments on commit 7027228

Please sign in to comment.