* [PATCH linux-next-2.6] gpio/ml_ioh_gpio: fix resource leak issue
@ 2011-01-05 9:02 Tomoya MORINAGA
0 siblings, 0 replies; only message in thread
From: Tomoya MORINAGA @ 2011-01-05 9:02 UTC (permalink / raw)
To: Samuel Ortiz, Andrew Morton, Rabin Vincent, Marc Zyngier,
Linus Walleij, Mark Brown, linux-kernel
Cc: qi.wang, yong.y.wang, joel.clark, kok.howg.ewe, Tomoya MORINAGA
(1) add gpiochip_remove processing in case gpiochip_add fails.
(2) for easy to read, move variable initialization to out of for-condition.
Reported-by: Andrew Morton. <akpm@linux-foundation.org>
Signed-off-by: Tomoya MORINAGA <tomoya-linux@dsn.okisemi.com>
---
drivers/gpio/ml_ioh_gpio.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/drivers/gpio/ml_ioh_gpio.c b/drivers/gpio/ml_ioh_gpio.c
index 4fa3224..cead8e6 100644
--- a/drivers/gpio/ml_ioh_gpio.c
+++ b/drivers/gpio/ml_ioh_gpio.c
@@ -208,7 +208,8 @@ static int __devinit ioh_gpio_probe(struct pci_dev *pdev,
goto err_kzalloc;
}
- for (i = 0, chip = chip_save; i < 8; i++, chip++) {
+ chip = chip_save;
+ for (i = 0; i < 8; i++, chip++) {
chip->dev = &pdev->dev;
chip->base = base;
chip->reg = chip->base;
@@ -228,6 +229,12 @@ static int __devinit ioh_gpio_probe(struct pci_dev *pdev,
return 0;
err_gpiochip_add:
+ for (; i != 0; i--) {
+ chip--;
+ ret = gpiochip_remove(&chip->gpio);
+ if (ret)
+ dev_err(&pdev->dev, "Failed gpiochip_remove(%d)\n", i);
+ }
kfree(chip_save);
err_kzalloc:
--
1.6.2.5
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2011-01-05 9:02 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-05 9:02 [PATCH linux-next-2.6] gpio/ml_ioh_gpio: fix resource leak issue Tomoya MORINAGA
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®