use the devm_kzalloc and no need of error path free's Signed-off-by: Devendra Naga <devendra.aaru@xxxxxxxxx> --- drivers/watchdog/at32ap700x_wdt.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/watchdog/at32ap700x_wdt.c b/drivers/watchdog/at32ap700x_wdt.c index 2896430..dc2e312 100644 --- a/drivers/watchdog/at32ap700x_wdt.c +++ b/drivers/watchdog/at32ap700x_wdt.c @@ -321,7 +321,7 @@ static int __init at32_wdt_probe(struct platform_device *pdev) return -ENXIO; } - wdt = kzalloc(sizeof(struct wdt_at32ap700x), GFP_KERNEL); + wdt = devm_kzalloc(&pdev->dev, sizeof(struct wdt_at32ap700x), GFP_KERNEL); if (!wdt) { dev_dbg(&pdev->dev, "no memory for wdt structure\n"); return -ENOMEM; @@ -329,9 +329,8 @@ static int __init at32_wdt_probe(struct platform_device *pdev) wdt->regs = ioremap(regs->start, resource_size(regs)); if (!wdt->regs) { - ret = -ENOMEM; dev_dbg(&pdev->dev, "could not map I/O memory\n"); - goto err_free; + return -ENOMEM; } spin_lock_init(&wdt->io_lock); @@ -377,9 +376,6 @@ err_register: platform_set_drvdata(pdev, NULL); err_iounmap: iounmap(wdt->regs); -err_free: - kfree(wdt); - wdt = NULL; return ret; } @@ -392,8 +388,6 @@ static int __exit at32_wdt_remove(struct platform_device *pdev) misc_deregister(&wdt->miscdev); iounmap(wdt->regs); - kfree(wdt); - wdt = NULL; platform_set_drvdata(pdev, NULL); } return 0; -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html