summaryrefslogtreecommitdiff
path: root/sound/soc
diff options
context:
space:
mode:
authorLuo Yifan <luoyifan@cmss.chinamobile.com>2024-11-07 09:59:36 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-12-09 10:31:39 +0100
commit0058f8ebfdb05156ed832bfdcf6a6b667f719d1b (patch)
tree4830696c8ad21e8c63649f1b57cd84f768253e30 /sound/soc
parentd525fc94249afccd43c985c275cc561a90e44007 (diff)
downloadlinux-0058f8ebfdb05156ed832bfdcf6a6b667f719d1b.tar.gz
linux-0058f8ebfdb05156ed832bfdcf6a6b667f719d1b.tar.bz2
linux-0058f8ebfdb05156ed832bfdcf6a6b667f719d1b.zip
ASoC: stm: Prevent potential division by zero in stm32_sai_get_clk_div()
[ Upstream commit 23569c8b314925bdb70dd1a7b63cfe6100868315 ] This patch checks if div is less than or equal to zero (div <= 0). If div is zero or negative, the function returns -EINVAL, ensuring the division operation is safe to perform. Signed-off-by: Luo Yifan <luoyifan@cmss.chinamobile.com> Reviewed-by: Olivier Moysan <olivier.moysan@foss.st.com> Link: https://patch.msgid.link/20241107015936.211902-1-luoyifan@cmss.chinamobile.com Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'sound/soc')
-rw-r--r--sound/soc/stm/stm32_sai_sub.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/sound/soc/stm/stm32_sai_sub.c b/sound/soc/stm/stm32_sai_sub.c
index 1b61110cb917..dcbcd1a59a3a 100644
--- a/sound/soc/stm/stm32_sai_sub.c
+++ b/sound/soc/stm/stm32_sai_sub.c
@@ -317,7 +317,7 @@ static int stm32_sai_get_clk_div(struct stm32_sai_sub_data *sai,
int div;
div = DIV_ROUND_CLOSEST(input_rate, output_rate);
- if (div > SAI_XCR1_MCKDIV_MAX(version)) {
+ if (div > SAI_XCR1_MCKDIV_MAX(version) || div <= 0) {
dev_err(&sai->pdev->dev, "Divider %d out of range\n", div);
return -EINVAL;
}