cpts_calc_mult_shift() has a potential divide-by-zero in this line: do_div(maxsec, freq); due to the fact that clk_get_rate() can return zero in certain error conditions. Add an explicit check to fix this. Fixes: 88f0f0b0bebf ("net: ethernet: ti: cpts: calc mult and shift from refclk freq") Signed-off-by: Miaoqian Lin --- This follows the same pattern as the fix in commit 7ca59947b5fc ("pwm: mediatek: Prevent divide-by-zero in pwm_mediatek_config()"). --- drivers/net/ethernet/ti/cpts.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/ti/cpts.c b/drivers/net/ethernet/ti/cpts.c index 2ba4c8795d60..e4e3409e7648 100644 --- a/drivers/net/ethernet/ti/cpts.c +++ b/drivers/net/ethernet/ti/cpts.c @@ -607,6 +607,8 @@ static void cpts_calc_mult_shift(struct cpts *cpts) u32 freq; freq = clk_get_rate(cpts->refclk); + if (!freq) + return; /* Calc the maximum number of seconds which we can run before * wrapping around. -- 2.39.5 (Apple Git-154)