[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241112103745.1653994-7-sashal@kernel.org>
Date: Tue, 12 Nov 2024 05:37:41 -0500
From: Sasha Levin <sashal@...nel.org>
To: linux-kernel@...r.kernel.org,
stable@...r.kernel.org
Cc: Luo Yifan <luoyifan@...s.chinamobile.com>,
Olivier Moysan <olivier.moysan@...s.st.com>,
Mark Brown <broonie@...nel.org>,
Sasha Levin <sashal@...nel.org>,
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 5.15 7/8] ASoC: stm: Prevent potential division by zero in stm32_sai_get_clk_div()
From: Luo Yifan <luoyifan@...s.chinamobile.com>
[ 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@...s.chinamobile.com>
Reviewed-by: Olivier Moysan <olivier.moysan@...s.st.com>
Link: https://patch.msgid.link/20241107015936.211902-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 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/stm/stm32_sai_sub.c b/sound/soc/stm/stm32_sai_sub.c
index aa9cdd93b5778..d71b4aecd269f 100644
--- a/sound/soc/stm/stm32_sai_sub.c
+++ b/sound/soc/stm/stm32_sai_sub.c
@@ -319,7 +319,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;
}
--
2.43.0
Powered by blists - more mailing lists