[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240917075250.19333-1-amishin@t-argos.ru>
Date: Tue, 17 Sep 2024 10:52:50 +0300
From: Aleksandr Mishin <amishin@...rgos.ru>
To: Maxime Ripard <mripard@...nel.org>
CC: Aleksandr Mishin <amishin@...rgos.ru>, Michael Turquette
<mturquette@...libre.com>, Stephen Boyd <sboyd@...nel.org>,
<linux-clk@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<lvc-project@...uxtesting.org>
Subject: [PATCH] clk: si5341: Prevent division by zero in si5341_output_clk_determine_rate()
In si5341_output_clk_determine_rate() division by zero is possible if the
following conditions are met:
- rate > (parent_rate / 2);
- (parent_rate / 2) is not multiple of rate;
- CLK_SET_RATE_PARENT flag is not set.
Add zero value check to prevent division by zero.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: 61c34af50c5f ("clk: si5341: Switch to determine_rate")
Signed-off-by: Aleksandr Mishin <amishin@...rgos.ru>
---
drivers/clk/clk-si5341.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/clk/clk-si5341.c b/drivers/clk/clk-si5341.c
index 6e8dd7387cfd..d0d68a5bba74 100644
--- a/drivers/clk/clk-si5341.c
+++ b/drivers/clk/clk-si5341.c
@@ -855,7 +855,7 @@ static int si5341_output_clk_determine_rate(struct clk_hw *hw,
} else {
/* We cannot change our parent's rate, report what we can do */
r /= rate;
- rate = req->best_parent_rate / (r << 1);
+ rate = (r << 1) ? req->best_parent_rate / (r << 1) : 0;
}
req->rate = rate;
--
2.30.2
Powered by blists - more mailing lists