[PATCH 1/1] at32ap700x-wdt: add iounmap if probe function fails

From: Hans-Christian Egtvedt
Date: Fri Jun 08 2007 - 07:17:13 EST


Signed-off-by: Hans-Christian Egtvedt <hcegtvedt@xxxxxxxxx>
---
drivers/char/watchdog/at32ap700x_wdt.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/char/watchdog/at32ap700x_wdt.c b/drivers/char/watchdog/at32ap700x_wdt.c
index 56ace8c..9b598d9 100644
--- a/drivers/char/watchdog/at32ap700x_wdt.c
+++ b/drivers/char/watchdog/at32ap700x_wdt.c
@@ -223,6 +223,11 @@ static int __init at32_wdt_probe(struct platform_device *pdev)
}

wdt->regs = ioremap(regs->start, regs->end - regs->start + 1);
+ if (!wdt->regs) {
+ ret = -ENOMEM;
+ dev_dbg(&pdev->dev, "could not map I/O memory\n");
+ goto err_free;
+ }
wdt->users = 0;
wdt->miscdev.minor = WATCHDOG_MINOR;
wdt->miscdev.name = "watchdog";
@@ -238,7 +243,7 @@ static int __init at32_wdt_probe(struct platform_device *pdev)
ret = misc_register(&wdt->miscdev);
if (ret) {
dev_dbg(&pdev->dev, "failed to register wdt miscdev\n");
- goto err_register;
+ goto err_iounmap;
}

platform_set_drvdata(pdev, wdt);
@@ -247,7 +252,9 @@ static int __init at32_wdt_probe(struct platform_device *pdev)

return 0;

-err_register:
+err_iounmap:
+ iounmap(wdt->regs);
+err_free:
kfree(wdt);
wdt = NULL;
return ret;
--
1.4.4.2


--=-HPl7lfPaFD+su+3aOXhX--

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/