summaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpio-mpc8xxx.c
diff options
context:
space:
mode:
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>2021-08-20 17:38:03 +0200
committerBartosz Golaszewski <bgolaszewski@baylibre.com>2021-08-31 12:10:12 +0200
commit7d6588931ccd4c09e70a08175cf2e0cf7fc3b869 (patch)
tree38e5b11c8bb4449c808543cda923c7c015c3949e /drivers/gpio/gpio-mpc8xxx.c
parent555bda42b0c1a5ffb72d3227c043e8afde778f1f (diff)
downloadlinux-stable-7d6588931ccd4c09e70a08175cf2e0cf7fc3b869.tar.gz
linux-stable-7d6588931ccd4c09e70a08175cf2e0cf7fc3b869.tar.bz2
linux-stable-7d6588931ccd4c09e70a08175cf2e0cf7fc3b869.zip
gpio: mpc8xxx: Fix a potential double iounmap call in 'mpc8xxx_probe()'
Commit 76c47d1449fc ("gpio: mpc8xxx: Add ACPI support") has switched to a managed version when dealing with 'mpc8xxx_gc->regs'. So the corresponding 'iounmap()' call in the error handling path and in the remove should be removed to avoid a double unmap. This also allows some simplification in the probe. All the error handling paths related to managed resources can be direct returns and a NULL check in what remains in the error handling path can be removed. Fixes: 76c47d1449fc ("gpio: mpc8xxx: Add ACPI support") Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Diffstat (limited to 'drivers/gpio/gpio-mpc8xxx.c')
-rw-r--r--drivers/gpio/gpio-mpc8xxx.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/drivers/gpio/gpio-mpc8xxx.c b/drivers/gpio/gpio-mpc8xxx.c
index b5cbeca5e300..f370ab548240 100644
--- a/drivers/gpio/gpio-mpc8xxx.c
+++ b/drivers/gpio/gpio-mpc8xxx.c
@@ -332,7 +332,7 @@ static int mpc8xxx_probe(struct platform_device *pdev)
mpc8xxx_gc->regs + GPIO_DIR, NULL,
BGPIOF_BIG_ENDIAN);
if (ret)
- goto err;
+ return ret;
dev_dbg(&pdev->dev, "GPIO registers are LITTLE endian\n");
} else {
ret = bgpio_init(gc, &pdev->dev, 4,
@@ -342,7 +342,7 @@ static int mpc8xxx_probe(struct platform_device *pdev)
BGPIOF_BIG_ENDIAN
| BGPIOF_BIG_ENDIAN_BYTE_ORDER);
if (ret)
- goto err;
+ return ret;
dev_dbg(&pdev->dev, "GPIO registers are BIG endian\n");
}
@@ -384,7 +384,7 @@ static int mpc8xxx_probe(struct platform_device *pdev)
if (ret) {
dev_err(&pdev->dev,
"GPIO chip registration failed with status %d\n", ret);
- goto err;
+ return ret;
}
mpc8xxx_gc->irqn = platform_get_irq(pdev, 0);
@@ -416,9 +416,7 @@ static int mpc8xxx_probe(struct platform_device *pdev)
return 0;
err:
- if (mpc8xxx_gc->irq)
- irq_domain_remove(mpc8xxx_gc->irq);
- iounmap(mpc8xxx_gc->regs);
+ irq_domain_remove(mpc8xxx_gc->irq);
return ret;
}
@@ -432,7 +430,6 @@ static int mpc8xxx_remove(struct platform_device *pdev)
}
gpiochip_remove(&mpc8xxx_gc->gc);
- iounmap(mpc8xxx_gc->regs);
return 0;
}