struct vt8500_rtc *vt8500_rtc;
        int ret;
 
-       vt8500_rtc = kzalloc(sizeof(struct vt8500_rtc), GFP_KERNEL);
+       vt8500_rtc = devm_kzalloc(&pdev->dev,
+                          sizeof(struct vt8500_rtc), GFP_KERNEL);
        if (!vt8500_rtc)
                return -ENOMEM;
 
        vt8500_rtc->res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        if (!vt8500_rtc->res) {
                dev_err(&pdev->dev, "No I/O memory resource defined\n");
-               ret = -ENXIO;
-               goto err_free;
+               return -ENXIO;
        }
 
        vt8500_rtc->irq_alarm = platform_get_irq(pdev, 0);
        if (vt8500_rtc->irq_alarm < 0) {
                dev_err(&pdev->dev, "No alarm IRQ resource defined\n");
-               ret = -ENXIO;
-               goto err_free;
+               return -ENXIO;
        }
 
        vt8500_rtc->res = request_mem_region(vt8500_rtc->res->start,
                                             "vt8500-rtc");
        if (vt8500_rtc->res == NULL) {
                dev_err(&pdev->dev, "failed to request I/O memory\n");
-               ret = -EBUSY;
-               goto err_free;
+               return -EBUSY;
        }
 
        vt8500_rtc->regbase = ioremap(vt8500_rtc->res->start,
 err_release:
        release_mem_region(vt8500_rtc->res->start,
                           resource_size(vt8500_rtc->res));
-err_free:
-       kfree(vt8500_rtc);
        return ret;
 }
 
        release_mem_region(vt8500_rtc->res->start,
                           resource_size(vt8500_rtc->res));
 
-       kfree(vt8500_rtc);
        platform_set_drvdata(pdev, NULL);
 
        return 0;