From: Olivier MOYSAN <olivier.moysan@foss.st.com>
To: Luo Yifan <luoyifan@cmss.chinamobile.com>
Cc: <arnaud.pouliquen@foss.st.com>, <broonie@kernel.org>,
<lgirdwood@gmail.com>, <linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>, <linux-sound@vger.kernel.org>,
<linux-stm32@st-md-mailman.stormreply.com>, <perex@perex.cz>,
<tiwai@suse.com>
Subject: Re: [PATCH] ASoC: stm: Prevent potential division by zero in stm32_sai_get_clk_div()
Date: Thu, 7 Nov 2024 10:48:12 +0100 [thread overview]
Message-ID: <e40beda1-56cf-4757-8eac-a9263f88e2fc@foss.st.com> (raw)
In-Reply-To: <20241107015936.211902-1-luoyifan@cmss.chinamobile.com>
On 11/7/24 02:59, Luo Yifan wrote:
> 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>
> ---
> 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 7bc4a96b7..43fb1dcb9 100644
> --- a/sound/soc/stm/stm32_sai_sub.c
> +++ b/sound/soc/stm/stm32_sai_sub.c
> @@ -317,7 +317,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;
> }
Reviewed-by: Olivier Moysan <olivier.moysan@foss.st.com>
thanks
next prev parent reply other threads:[~2024-11-07 9:51 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-06 1:46 [PATCH] ASoC: stm: Prevent potential division by zero in stm32_sai_mclk_round_rate() Luo Yifan
2024-11-06 9:27 ` Olivier MOYSAN
2024-11-07 1:45 ` Luo Yifan
2024-11-07 1:59 ` [PATCH] ASoC: stm: Prevent potential division by zero in stm32_sai_get_clk_div() Luo Yifan
2024-11-07 9:48 ` Olivier MOYSAN [this message]
2024-11-07 15:35 ` [PATCH] ASoC: stm: Prevent potential division by zero in stm32_sai_mclk_round_rate() Mark Brown
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=e40beda1-56cf-4757-8eac-a9263f88e2fc@foss.st.com \
--to=olivier.moysan@foss.st.com \
--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=perex@perex.cz \
--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
all inboxes | Powered by JetHome®