mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 18:41:58 +09:00
ASoC: stm: Prevent potential division by zero in stm32_sai_get_clk_div()
[ 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>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
5d1838582d
commit
dccfd9a4df
@@ -317,7 +317,7 @@ static int stm32_sai_get_clk_div(struct stm32_sai_sub_data *sai,
|
|||||||
int div;
|
int div;
|
||||||
|
|
||||||
div = DIV_ROUND_CLOSEST(input_rate, output_rate);
|
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);
|
dev_err(&sai->pdev->dev, "Divider %d out of range\n", div);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user