[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241112103605.1652910-13-sashal@kernel.org>
Date: Tue, 12 Nov 2024 05:35:55 -0500
From: Sasha Levin <sashal@...nel.org>
To: linux-kernel@...r.kernel.org,
stable@...r.kernel.org
Cc: Luo Yifan <luoyifan@...s.chinamobile.com>,
Mark Brown <broonie@...nel.org>,
Sasha Levin <sashal@...nel.org>,
olivier.moysan@...s.st.com,
arnaud.pouliquen@...s.st.com,
lgirdwood@...il.com,
perex@...ex.cz,
tiwai@...e.com,
mcoquelin.stm32@...il.com,
alexandre.torgue@...s.st.com,
alsa-devel@...a-project.org,
linux-sound@...r.kernel.org,
linux-stm32@...md-mailman.stormreply.com,
linux-arm-kernel@...ts.infradead.org
Subject: [PATCH AUTOSEL 6.11 13/16] ASoC: stm: Prevent potential division by zero in stm32_sai_mclk_round_rate()
From: Luo Yifan <luoyifan@...s.chinamobile.com>
[ 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@...s.chinamobile.com>
Link: https://patch.msgid.link/20241106014654.206860-1-luoyifan@cmss.chinamobile.com
Signed-off-by: Mark Brown <broonie@...nel.org>
Signed-off-by: Sasha Levin <sashal@...nel.org>
---
sound/soc/stm/stm32_sai_sub.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sound/soc/stm/stm32_sai_sub.c b/sound/soc/stm/stm32_sai_sub.c
index ad2492efb1cdc..19307812ec765 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;
--
2.43.0
Powered by blists - more mailing lists