From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Luo Yifan <luoyifan@cmss.chinamobile.com>,
Olivier Moysan <olivier.moysan@foss.st.com>,
Mark Brown <broonie@kernel.org>, Sasha Levin <sashal@kernel.org>,
arnaud.pouliquen@foss.st.com, lgirdwood@gmail.com,
perex@perex.cz, tiwai@suse.com, mcoquelin.stm32@gmail.com,
alexandre.torgue@foss.st.com, alsa-devel@alsa-project.org,
linux-sound@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org
Subject: [PATCH AUTOSEL 5.15 7/8] ASoC: stm: Prevent potential division by zero in stm32_sai_get_clk_div()
Date: Tue, 12 Nov 2024 05:37:41 -0500 [thread overview]
Message-ID: <20241112103745.1653994-7-sashal@kernel.org> (raw)
In-Reply-To: <20241112103745.1653994-1-sashal@kernel.org>
From: Luo Yifan <luoyifan@cmss.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@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>
---
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
next prev parent reply other threads:[~2024-11-12 10:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-12 10:37 [PATCH AUTOSEL 5.15 1/8] soc: qcom: Add check devm_kasprintf() returned value Sasha Levin
2024-11-12 10:37 ` [PATCH AUTOSEL 5.15 2/8] regulator: rk808: Add apply_bit for BUCK3 on RK809 Sasha Levin
2024-11-12 10:37 ` [PATCH AUTOSEL 5.15 3/8] platform/x86: dell-smbios-base: Extends support to Alienware products Sasha Levin
2024-11-12 10:37 ` [PATCH AUTOSEL 5.15 4/8] platform/x86: dell-wmi-base: Handle META key Lock/Unlock events Sasha Levin
2024-11-12 10:37 ` [PATCH AUTOSEL 5.15 5/8] can: j1939: fix error in J1939 documentation Sasha Levin
2024-11-12 10:37 ` [PATCH AUTOSEL 5.15 6/8] ASoC: stm: Prevent potential division by zero in stm32_sai_mclk_round_rate() Sasha Levin
2024-11-12 10:37 ` Sasha Levin [this message]
2024-11-12 10:37 ` [PATCH AUTOSEL 5.15 8/8] proc/softirqs: replace seq_printf with seq_put_decimal_ull_width Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241112103745.1653994-7-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=alexandre.torgue@foss.st.com \
--cc=alsa-devel@alsa-project.org \
--cc=arnaud.pouliquen@foss.st.com \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=luoyifan@cmss.chinamobile.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=olivier.moysan@foss.st.com \
--cc=perex@perex.cz \
--cc=stable@vger.kernel.org \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox