lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e40beda1-56cf-4757-8eac-a9263f88e2fc@foss.st.com>
Date: Thu, 7 Nov 2024 10:48:12 +0100
From: Olivier MOYSAN <olivier.moysan@...s.st.com>
To: Luo Yifan <luoyifan@...s.chinamobile.com>
CC: <arnaud.pouliquen@...s.st.com>, <broonie@...nel.org>,
        <lgirdwood@...il.com>, <linux-arm-kernel@...ts.infradead.org>,
        <linux-kernel@...r.kernel.org>, <linux-sound@...r.kernel.org>,
        <linux-stm32@...md-mailman.stormreply.com>, <perex@...ex.cz>,
        <tiwai@...e.com>
Subject: Re: [PATCH] ASoC: stm: Prevent potential division by zero in
 stm32_sai_get_clk_div()

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@...s.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@...s.st.com>

thanks

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ