Hi Tigran, On Thu, 27 Mar 2025 at 16:13, Tigran Sogomonian <tsogomonian@xxxxxxxxxxxxx> wrote: > 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@xxxxxxxxxxxxx> Thanks for your patch! > --- a/drivers/clk/renesas/rcar-gen3-cpg.c > +++ b/drivers/clk/renesas/rcar-gen3-cpg.c > @@ -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; prate can never be zero, as req->best_parent_rate is always larger or equal than zclk->max_rate, and zclk->fixed_div is a very small number (2 or 4). > 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) > diff --git a/drivers/clk/renesas/rcar-gen4-cpg.c b/drivers/clk/renesas/rcar-gen4-cpg.c > index 31aa790fd003..4c9a7d699290 100644 > --- a/drivers/clk/renesas/rcar-gen4-cpg.c > +++ b/drivers/clk/renesas/rcar-gen4-cpg.c > @@ -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; Likewise. > 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) Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds