Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/audio/volume/volume_ipc3.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ int volume_init(struct processing_module *mod)
break;
default:
comp_err(dev, "invalid ramp type %d", vol->ramp);
mod_free(mod, cd);
mod_free(mod, cd->vol);
mod_free(mod, cd);
return -EINVAL;
}

Expand Down
15 changes: 13 additions & 2 deletions src/audio/volume/volume_ipc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,15 @@ int volume_init(struct processing_module *mod)
return -EINVAL;
}

/* the per-channel config[] array is read below for every channel, so
* the init payload must be large enough to hold them all
*/
if (cfg->size < sizeof(*vol) + channels_count * sizeof(vol->config[0])) {
comp_err(dev, "Invalid init payload size %zu for %u channels",
cfg->size, channels_count);
return -EINVAL;
}
Comment on lines +133 to +137

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No overflow here: channels_count is validated to be in [1, SOF_IPC_MAX_CHANNELS] (== 8) a few lines above, before this size check, so channels_count * sizeof(vol->config[0]) is bounded by 8 * a small struct and can't overflow size_t.


cd = mod_zalloc(mod, sizeof(struct vol_data));
if (!cd)
return -ENOMEM;
Expand Down Expand Up @@ -268,8 +277,10 @@ static int volume_set_attenuation(struct processing_module *mod, const uint8_t *
struct comp_dev *dev = mod->dev;
uint32_t attenuation;

/* only support attenuation in format of 32bit */
if (data_size > sizeof(uint32_t)) {
/* only support attenuation in format of 32bit; the payload is
* dereferenced as a uint32_t below so it must be exactly that size
*/
if (data_size != (int)sizeof(uint32_t)) {
comp_err(dev, "attenuation data size %d is incorrect", data_size);
return -EINVAL;
}
Expand Down
Loading