soc/qbman: Fix resource leak on portal probing error path
authorClaudiu Manoil <claudiu.manoil@nxp.com>
Wed, 16 Nov 2016 14:40:17 +0000 (16:40 +0200)
committerScott Wood <oss@buserror.net>
Wed, 23 Nov 2016 07:23:41 +0000 (01:23 -0600)
In case init_pcfg() returns with error the CI region
must be unmapped too.

Signed-off-by: Claudiu Manoil <claudiu.manoil@nxp.com>
Signed-off-by: Scott Wood <oss@buserror.net>
drivers/soc/fsl/qbman/bman_portal.c
drivers/soc/fsl/qbman/qman_portal.c

index 6579cc18811ac1040ef8ebfa073730371b6d625d..dd3f5d7617d253a5acd5dbb912bc843ec93bab7d 100644 (file)
@@ -146,15 +146,19 @@ static int bman_portal_probe(struct platform_device *pdev)
        pcfg->irq = irq;
 
        va = ioremap_prot(addr_phys[0]->start, resource_size(addr_phys[0]), 0);
-       if (!va)
+       if (!va) {
+               dev_err(dev, "ioremap::CE failed\n");
                goto err_ioremap1;
+       }
 
        pcfg->addr_virt[DPAA_PORTAL_CE] = va;
 
        va = ioremap_prot(addr_phys[1]->start, resource_size(addr_phys[1]),
                          _PAGE_GUARDED | _PAGE_NO_CACHE);
-       if (!va)
+       if (!va) {
+               dev_err(dev, "ioremap::CI failed\n");
                goto err_ioremap2;
+       }
 
        pcfg->addr_virt[DPAA_PORTAL_CI] = va;
 
@@ -170,8 +174,10 @@ static int bman_portal_probe(struct platform_device *pdev)
        spin_unlock(&bman_lock);
        pcfg->cpu = cpu;
 
-       if (!init_pcfg(pcfg))
-               goto err_ioremap2;
+       if (!init_pcfg(pcfg)) {
+               dev_err(dev, "portal init failed\n");
+               goto err_portal_init;
+       }
 
        /* clear irq affinity if assigned cpu is offline */
        if (!cpu_online(cpu))
@@ -179,10 +185,11 @@ static int bman_portal_probe(struct platform_device *pdev)
 
        return 0;
 
+err_portal_init:
+       iounmap(pcfg->addr_virt[DPAA_PORTAL_CI]);
 err_ioremap2:
        iounmap(pcfg->addr_virt[DPAA_PORTAL_CE]);
 err_ioremap1:
-       dev_err(dev, "ioremap failed\n");
        return -ENXIO;
 }
 
index 0c3e8adae647b70e7342aed12f65f5ba5b0db973..6651168333e16fc8f5d05dc73b5892010ece8682 100644 (file)
@@ -280,15 +280,19 @@ static int qman_portal_probe(struct platform_device *pdev)
        pcfg->irq = irq;
 
        va = ioremap_prot(addr_phys[0]->start, resource_size(addr_phys[0]), 0);
-       if (!va)
+       if (!va) {
+               dev_err(dev, "ioremap::CE failed\n");
                goto err_ioremap1;
+       }
 
        pcfg->addr_virt[DPAA_PORTAL_CE] = va;
 
        va = ioremap_prot(addr_phys[1]->start, resource_size(addr_phys[1]),
                          _PAGE_GUARDED | _PAGE_NO_CACHE);
-       if (!va)
+       if (!va) {
+               dev_err(dev, "ioremap::CI failed\n");
                goto err_ioremap2;
+       }
 
        pcfg->addr_virt[DPAA_PORTAL_CI] = va;
 
@@ -306,8 +310,10 @@ static int qman_portal_probe(struct platform_device *pdev)
        spin_unlock(&qman_lock);
        pcfg->cpu = cpu;
 
-       if (!init_pcfg(pcfg))
-               goto err_ioremap2;
+       if (!init_pcfg(pcfg)) {
+               dev_err(dev, "portal init failed\n");
+               goto err_portal_init;
+       }
 
        /* clear irq affinity if assigned cpu is offline */
        if (!cpu_online(cpu))
@@ -315,10 +321,11 @@ static int qman_portal_probe(struct platform_device *pdev)
 
        return 0;
 
+err_portal_init:
+       iounmap(pcfg->addr_virt[DPAA_PORTAL_CI]);
 err_ioremap2:
        iounmap(pcfg->addr_virt[DPAA_PORTAL_CE]);
 err_ioremap1:
-       dev_err(dev, "ioremap failed\n");
        return -ENXIO;
 }