In order to be free automatically and make the cleanup paths more simple,
use devm_kzalloc() instead of kmalloc().
Signed-off-by: Sangjung Woo <sangjung.woo@samsung.com>
Cc: Joe Perches <joe@perches.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
if (ret)
goto err_req;
- rtc = kmalloc(sizeof(*rtc), GFP_KERNEL);
+ rtc = devm_kzalloc(&dev->dev, sizeof(*rtc), GFP_KERNEL);
if (!rtc) {
ret = -ENOMEM;
goto err_rtc;
rtc->base = ioremap(dev->res.start, resource_size(&dev->res));
if (!rtc->base) {
ret = -ENOMEM;
- goto err_map;
+ goto err_rtc;
}
__raw_writel(0, rtc->base + RTC_CR);
free_irq(dev->irq[0], rtc);
err_irq:
iounmap(rtc->base);
- err_map:
- kfree(rtc);
err_rtc:
amba_release_regions(dev);
err_req:
free_irq(dev->irq[0], rtc);
rtc_device_unregister(rtc->rtc);
iounmap(rtc->base);
- kfree(rtc);
amba_release_regions(dev);
return 0;