summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorLuo Yifan <luoyifan@cmss.chinamobile.com>2024-11-06 09:46:54 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-12-09 10:31:39 +0100
commitd525fc94249afccd43c985c275cc561a90e44007 (patch)
tree9cca38a7bcb13bdd85ff2cc5775e07fa9f2bcbac /sound
parent1423de2c7ba11d2176585ff1ca29fae2b58eceed (diff)
downloadlinux-d525fc94249afccd43c985c275cc561a90e44007.tar.gz
linux-d525fc94249afccd43c985c275cc561a90e44007.tar.bz2
linux-d525fc94249afccd43c985c275cc561a90e44007.zip
ASoC: stm: Prevent potential division by zero in stm32_sai_mclk_round_rate()
[ Upstream commit 63c1c87993e0e5bb11bced3d8224446a2bc62338 ] 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 (*prate / div) is safe to perform. Signed-off-by: Luo Yifan <luoyifan@cmss.chinamobile.com> Link: https://patch.msgid.link/20241106014654.206860-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')
-rw-r--r--sound/soc/stm/stm32_sai_sub.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sound/soc/stm/stm32_sai_sub.c b/sound/soc/stm/stm32_sai_sub.c
index 0acc848c1f00..1b61110cb917 100644
--- a/sound/soc/stm/stm32_sai_sub.c
+++ b/sound/soc/stm/stm32_sai_sub.c
@@ -378,8 +378,8 @@ static long stm32_sai_mclk_round_rate(struct clk_hw *hw, unsigned long rate,
int div;
div = stm32_sai_get_clk_div(sai, *prate, rate);
- if (div < 0)
- return div;
+ if (div <= 0)
+ return -EINVAL;
mclk->freq = *prate / div;