@@ -205,6 +205,8 @@ static int cpg_z_clk_determine_rate(struct clk_hw *hw,
prate * zclk->fixed_div);
prate = req->best_parent_rate / zclk->fixed_div;
+ if (prate == 0)
+ return -EINVAL;
min_mult = max(div64_ul(req->min_rate * 32ULL, prate), 1ULL);
max_mult = min(div64_ul(req->max_rate * 32ULL, prate), 32ULL);
if (max_mult < min_mult)
@@ -308,6 +308,8 @@ static int cpg_z_clk_determine_rate(struct clk_hw *hw,
prate * zclk->fixed_div);
prate = req->best_parent_rate / zclk->fixed_div;
+ if (prate == 0)
+ return -EINVAL;
min_mult = max(div64_ul(req->min_rate * 32ULL, prate), 1ULL);
max_mult = min(div64_ul(req->max_rate * 32ULL, prate), 32ULL);
if (max_mult < min_mult)
To avoid division by zero, a check was added to the prate variable, since no guarantees were found that it could not be equal to zero. Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Tigran Sogomonian <tsogomonian@astralinux.ru> --- drivers/clk/renesas/rcar-gen3-cpg.c | 2 ++ drivers/clk/renesas/rcar-gen4-cpg.c | 2 ++ 2 files changed, 4 insertions(+)