Skip to content

Commit

Permalink
gpio: mpc8xxx: Fix a potential double iounmap call in 'mpc8xxx_probe()'
Browse files Browse the repository at this point in the history
[ Upstream commit 7d65889 ]

Commit 76c47d1 ("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: 76c47d1 ("gpio: mpc8xxx: Add ACPI support")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
tititiou36 authored and gregkh committed Sep 22, 2021
1 parent 8c7ba0e commit 450adfa
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions drivers/gpio/gpio-mpc8xxx.c
Expand Up @@ -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,
Expand All @@ -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");
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}

Expand All @@ -432,7 +430,6 @@ static int mpc8xxx_remove(struct platform_device *pdev)
}

gpiochip_remove(&mpc8xxx_gc->gc);
iounmap(mpc8xxx_gc->regs);

return 0;
}
Expand Down

0 comments on commit 450adfa

Please sign in to comment.