dai-zephyr: possible division-by-zero if max_block_count is zero

If the max_block_count attribute is zero, this may lead to
division by zero error. Handle this explicitly but reporting
error if max_block_count is zero.

Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
This commit is contained in:
Adrian Bonislawski 2023-06-16 09:24:16 +02:00 committed by Kai Vehmanen
parent fe83601406
commit 4a0443812b
1 changed files with 5 additions and 0 deletions

View File

@ -639,6 +639,11 @@ static int dai_playback_params(struct dai_data *dd, struct comp_dev *dev, uint32
goto out; goto out;
} }
if (!max_block_count) {
comp_err(dev, "dai_playback_params(): invalid max-block-count of zero");
goto out;
}
if (max_block_count < period_count) { if (max_block_count < period_count) {
comp_dbg(dev, "dai_playback_params(): block count = %d not supported by DMA", period_count); comp_dbg(dev, "dai_playback_params(): block count = %d not supported by DMA", period_count);
buf_size = period_count * period_bytes; buf_size = period_count * period_bytes;