@@ -1225,17 +1225,13 @@ static int armada_drm_crtc_create(struct drm_device *drm, struct device *dev,
ret = devm_request_irq(dev, irq, armada_drm_irq, 0, "armada_drm_crtc",
dcrtc);
- if (ret < 0) {
- kfree(dcrtc);
- return ret;
- }
+ if (ret < 0)
+ goto err_crtc;
if (dcrtc->variant->init) {
ret = dcrtc->variant->init(dcrtc, dev);
- if (ret) {
- kfree(dcrtc);
- return ret;
- }
+ if (ret)
+ goto err_crtc;
}
/* Ensure AXI pipeline is enabled */
@@ -1247,15 +1243,14 @@ static int armada_drm_crtc_create(struct drm_device *drm, struct device *dev,
primary = kzalloc(sizeof(*primary), GFP_KERNEL);
if (!primary) {
- kfree(dcrtc);
- return -ENOMEM;
+ ret = -ENOMEM;
+ goto err_crtc;
}
ret = armada_drm_plane_init(primary);
if (ret) {
- kfree(dcrtc);
kfree(primary);
- return ret;
+ goto err_crtc;
}
ret = drm_universal_plane_init(drm, &primary->base, 0,
@@ -1265,17 +1260,14 @@ static int armada_drm_crtc_create(struct drm_device *drm, struct device *dev,
NULL,
DRM_PLANE_TYPE_PRIMARY, NULL);
if (ret) {
- kfree(dcrtc);
kfree(primary);
- return ret;
+ goto err_crtc;
}
ret = drm_crtc_init_with_planes(drm, &dcrtc->crtc, &primary->base, NULL,
&armada_crtc_funcs, NULL);
- if (ret) {
- kfree(dcrtc);
+ if (ret)
goto err_crtc_init;
- }
drm_crtc_helper_add(&dcrtc->crtc, &armada_crtc_helper_funcs);
@@ -1288,6 +1280,9 @@ static int armada_drm_crtc_create(struct drm_device *drm, struct device *dev,
err_crtc_init:
primary->base.funcs->destroy(&primary->base);
+err_crtc:
+ kfree(dcrtc);
+
return ret;
}