MLK-20213-1 soc: imx: gpc: fix coverity issue
authorAnson Huang <Anson.Huang@nxp.com>
Sat, 3 Nov 2018 04:30:31 +0000 (12:30 +0800)
committerLeonard Crestez <leonard.crestez@nxp.com>
Wed, 17 Apr 2019 23:51:34 +0000 (02:51 +0300)
This patch fixes coverity issue of "divide by 0".

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Reviewed-by: Bai Ping <ping.bai@nxp.com>
Signed-off-by: Arulpandiyan Vadivel <arulpandiyan_vadivel@mentor.com>
drivers/soc/imx/gpc.c

index b45393e..d507dac 100644 (file)
@@ -138,6 +138,11 @@ static void _imx6_pm_domain_power_on(struct generic_pm_domain *genpd)
        int i;
        u32 val, ipg_rate = clk_get_rate(ipg_clk);
 
+       if (ipg_rate == 0) {
+               WARN_ON(1);
+               return;
+       }
+
        /* Enable reset clocks for all devices in the domain */
        for (i = 0; i < pd->num_clks; i++)
                clk_prepare_enable(pd->clk[i]);
@@ -187,6 +192,11 @@ static int imx6_pm_dispmix_on(struct generic_pm_domain *genpd)
        u32 ipg_rate = clk_get_rate(ipg_clk);
        int i;
 
+       if (ipg_rate == 0) {
+               WARN_ON(1);
+               return -EINVAL;
+       }
+
        if ((cpu_is_imx6sl() &&
                imx_get_soc_revision() >= IMX_CHIP_REVISION_1_2) || cpu_is_imx6sx()) {