]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
clk: imx: pllv3: fix potential 'divide by zero' in av_get_rate()
authorGiulio Benetti <giulio.benetti@benettiengineering.com>
Fri, 17 Jan 2020 12:06:41 +0000 (13:06 +0100)
committerLukasz Majewski <lukma@denx.de>
Sun, 26 Jan 2020 20:57:08 +0000 (21:57 +0100)
Guard 'mfd==0' to prevent 'divide by zero' issue in
clk_pplv3_av_get_rate(). If it is 0, let's return with EIO since mfd
should never be 0 at all.

Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
drivers/clk/imx/clk-pllv3.c

index a540a5b68c65be80fb4911aeb776d2888453e6ef..72e675061548986c0b854e5f0a6f1f710a12c8a0 100644 (file)
@@ -163,6 +163,9 @@ static ulong clk_pllv3_av_get_rate(struct clk *clk)
        u32 div = readl(pll->base) & pll->div_mask;
        u64 temp64 = (u64)parent_rate;
 
+       if (mfd == 0)
+               return -EIO;
+
        temp64 *= mfn;
        do_div(temp64, mfd);