mirror of
https://github.com/torvalds/linux.git
synced 2024-11-13 23:51:39 +00:00
ASoC: stm: Prevent potential division by zero in stm32_sai_mclk_round_rate()
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>
This commit is contained in:
parent
8c21e40e1e
commit
63c1c87993
@ -378,8 +378,8 @@ static long stm32_sai_mclk_round_rate(struct clk_hw *hw, unsigned long rate,
|
|||||||
int div;
|
int div;
|
||||||
|
|
||||||
div = stm32_sai_get_clk_div(sai, *prate, rate);
|
div = stm32_sai_get_clk_div(sai, *prate, rate);
|
||||||
if (div < 0)
|
if (div <= 0)
|
||||||
return div;
|
return -EINVAL;
|
||||||
|
|
||||||
mclk->freq = *prate / div;
|
mclk->freq = *prate / div;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user