MLK-16177: soc: imx: Fix resources release in pm-domains detach_dev function
authorMihai Serban <mihai.serban@nxp.com>
Wed, 9 Aug 2017 13:54:45 +0000 (16:54 +0300)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 20:36:30 +0000 (15:36 -0500)
Because of a typo the resources allocated in imx8_attach_dev were not
correctly released by imx8_detach_dev.

Fixes: a0fb334819bb ("MLK16147-2 soc:imx Add support to save/restore clock rates")
Signed-off-by: Mihai Serban <mihai.serban@nxp.com>
Reviewed-by: Ranjani Vaidyanathan <Ranjani.Vaidyanathan@nxp.com>
drivers/soc/imx/pm-domains.c

index 5f94b47..90cd2df 100644 (file)
@@ -182,15 +182,15 @@ static int imx8_attach_dev(struct generic_pm_domain *genpd, struct device *dev)
 static void imx8_detach_dev(struct generic_pm_domain *genpd, struct device *dev)
 {
        struct imx8_pm_domain *pd;
-       struct imx8_pm_rsrc_clks *imx8_rsrc_clk;
+       struct imx8_pm_rsrc_clks *imx8_rsrc_clk, *tmp;
 
        pd = container_of(genpd, struct imx8_pm_domain, pd);
 
        /* Free all the clock entry nodes. */
-       if (!list_empty(&pd->clks))
+       if (list_empty(&pd->clks))
                return;
 
-       list_for_each_entry(imx8_rsrc_clk, &pd->clks, node) {
+       list_for_each_entry_safe(imx8_rsrc_clk, tmp, &pd->clks, node) {
                list_del(&imx8_rsrc_clk->node);
                devm_kfree(dev, imx8_rsrc_clk);
        }