From 4a0443812b38642fac0cec505ae322f900360685 Mon Sep 17 00:00:00 2001 From: Adrian Bonislawski Date: Fri, 16 Jun 2023 09:24:16 +0200 Subject: [PATCH] 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 --- src/audio/dai-zephyr.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/audio/dai-zephyr.c b/src/audio/dai-zephyr.c index 1085f327f..12e4dfd50 100644 --- a/src/audio/dai-zephyr.c +++ b/src/audio/dai-zephyr.c @@ -639,6 +639,11 @@ static int dai_playback_params(struct dai_data *dd, struct comp_dev *dev, uint32 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) { comp_dbg(dev, "dai_playback_params(): block count = %d not supported by DMA", period_count); buf_size = period_count * period_bytes;