OMAP3/4: l3: fix omap3_l3_probe error path

l3_smx:
- Add missing free_irq and remove an empty goto label.

l3_noc:
- If kzalloc fails driver shouldn't continue with a NULL pointer.
- Add missing free_irq and remove empty goto labels.
- Safe to assume that if we reached the end point of execution
  without errors, then return value is 0, so replacing instead
  another goto.

Signed-off-by: Omar Ramirez Luna <omar.ramirez@ti.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
This commit is contained in:
omar ramirez 2011-04-18 16:39:41 +00:00 committed by Tony Lindgren
parent 11383a9bcc
commit 7529b70386
2 changed files with 26 additions and 31 deletions

View File

@ -132,49 +132,49 @@ static int __init omap4_l3_probe(struct platform_device *pdev)
l3 = kzalloc(sizeof(*l3), GFP_KERNEL); l3 = kzalloc(sizeof(*l3), GFP_KERNEL);
if (!l3) if (!l3)
ret = -ENOMEM; return -ENOMEM;
platform_set_drvdata(pdev, l3); platform_set_drvdata(pdev, l3);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) { if (!res) {
dev_err(&pdev->dev, "couldn't find resource 0\n"); dev_err(&pdev->dev, "couldn't find resource 0\n");
ret = -ENODEV; ret = -ENODEV;
goto err1; goto err0;
} }
l3->l3_base[0] = ioremap(res->start, resource_size(res)); l3->l3_base[0] = ioremap(res->start, resource_size(res));
if (!(l3->l3_base[0])) { if (!(l3->l3_base[0])) {
dev_err(&pdev->dev, "ioremap failed\n"); dev_err(&pdev->dev, "ioremap failed\n");
ret = -ENOMEM; ret = -ENOMEM;
goto err2; goto err0;
} }
res = platform_get_resource(pdev, IORESOURCE_MEM, 1); res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
if (!res) { if (!res) {
dev_err(&pdev->dev, "couldn't find resource 1\n"); dev_err(&pdev->dev, "couldn't find resource 1\n");
ret = -ENODEV; ret = -ENODEV;
goto err3; goto err1;
} }
l3->l3_base[1] = ioremap(res->start, resource_size(res)); l3->l3_base[1] = ioremap(res->start, resource_size(res));
if (!(l3->l3_base[1])) { if (!(l3->l3_base[1])) {
dev_err(&pdev->dev, "ioremap failed\n"); dev_err(&pdev->dev, "ioremap failed\n");
ret = -ENOMEM; ret = -ENOMEM;
goto err4; goto err1;
} }
res = platform_get_resource(pdev, IORESOURCE_MEM, 2); res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
if (!res) { if (!res) {
dev_err(&pdev->dev, "couldn't find resource 2\n"); dev_err(&pdev->dev, "couldn't find resource 2\n");
ret = -ENODEV; ret = -ENODEV;
goto err5; goto err2;
} }
l3->l3_base[2] = ioremap(res->start, resource_size(res)); l3->l3_base[2] = ioremap(res->start, resource_size(res));
if (!(l3->l3_base[2])) { if (!(l3->l3_base[2])) {
dev_err(&pdev->dev, "ioremap failed\n"); dev_err(&pdev->dev, "ioremap failed\n");
ret = -ENOMEM; ret = -ENOMEM;
goto err6; goto err2;
} }
/* /*
@ -187,7 +187,7 @@ static int __init omap4_l3_probe(struct platform_device *pdev)
if (ret) { if (ret) {
pr_crit("L3: request_irq failed to register for 0x%x\n", pr_crit("L3: request_irq failed to register for 0x%x\n",
OMAP44XX_IRQ_L3_DBG); OMAP44XX_IRQ_L3_DBG);
goto err7; goto err3;
} }
l3->debug_irq = irq; l3->debug_irq = irq;
@ -198,24 +198,22 @@ static int __init omap4_l3_probe(struct platform_device *pdev)
if (ret) { if (ret) {
pr_crit("L3: request_irq failed to register for 0x%x\n", pr_crit("L3: request_irq failed to register for 0x%x\n",
OMAP44XX_IRQ_L3_APP); OMAP44XX_IRQ_L3_APP);
goto err8; goto err4;
} }
l3->app_irq = irq; l3->app_irq = irq;
goto err0; return 0;
err8:
err7:
iounmap(l3->l3_base[2]);
err6:
err5:
iounmap(l3->l3_base[1]);
err4: err4:
free_irq(l3->debug_irq, l3);
err3: err3:
iounmap(l3->l3_base[0]); iounmap(l3->l3_base[2]);
err2: err2:
iounmap(l3->l3_base[1]);
err1: err1:
kfree(l3); iounmap(l3->l3_base[0]);
err0: err0:
kfree(l3);
return ret; return ret;
} }

View File

@ -228,10 +228,8 @@ static int __init omap3_l3_probe(struct platform_device *pdev)
int ret; int ret;
l3 = kzalloc(sizeof(*l3), GFP_KERNEL); l3 = kzalloc(sizeof(*l3), GFP_KERNEL);
if (!l3) { if (!l3)
ret = -ENOMEM; return -ENOMEM;
goto err0;
}
platform_set_drvdata(pdev, l3); platform_set_drvdata(pdev, l3);
@ -239,13 +237,13 @@ static int __init omap3_l3_probe(struct platform_device *pdev)
if (!res) { if (!res) {
dev_err(&pdev->dev, "couldn't find resource\n"); dev_err(&pdev->dev, "couldn't find resource\n");
ret = -ENODEV; ret = -ENODEV;
goto err1; goto err0;
} }
l3->rt = ioremap(res->start, resource_size(res)); l3->rt = ioremap(res->start, resource_size(res));
if (!(l3->rt)) { if (!(l3->rt)) {
dev_err(&pdev->dev, "ioremap failed\n"); dev_err(&pdev->dev, "ioremap failed\n");
ret = -ENOMEM; ret = -ENOMEM;
goto err2; goto err0;
} }
l3->debug_irq = platform_get_irq(pdev, 0); l3->debug_irq = platform_get_irq(pdev, 0);
@ -254,7 +252,7 @@ static int __init omap3_l3_probe(struct platform_device *pdev)
"l3-debug-irq", l3); "l3-debug-irq", l3);
if (ret) { if (ret) {
dev_err(&pdev->dev, "couldn't request debug irq\n"); dev_err(&pdev->dev, "couldn't request debug irq\n");
goto err3; goto err1;
} }
l3->app_irq = platform_get_irq(pdev, 1); l3->app_irq = platform_get_irq(pdev, 1);
@ -264,18 +262,17 @@ static int __init omap3_l3_probe(struct platform_device *pdev)
if (ret) { if (ret) {
dev_err(&pdev->dev, "couldn't request app irq\n"); dev_err(&pdev->dev, "couldn't request app irq\n");
goto err4; goto err2;
} }
goto err0; return 0;
err4:
err3:
iounmap(l3->rt);
err2: err2:
free_irq(l3->debug_irq, l3);
err1: err1:
kfree(l3); iounmap(l3->rt);
err0: err0:
kfree(l3);
return ret; return ret;
} }