Commit b22c361e authored by Russell King's avatar Russell King Committed by Greg Kroah-Hartman

drm/armada: fix leak of crtc structure


[ Upstream commit 33cd3c07 ]

Fix the leak of the CRTC structure in the failure paths of
armada_drm_crtc_create().
Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent cce422b3
...@@ -1182,17 +1182,13 @@ static int armada_drm_crtc_create(struct drm_device *drm, struct device *dev, ...@@ -1182,17 +1182,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", ret = devm_request_irq(dev, irq, armada_drm_irq, 0, "armada_drm_crtc",
dcrtc); dcrtc);
if (ret < 0) { if (ret < 0)
kfree(dcrtc); goto err_crtc;
return ret;
}
if (dcrtc->variant->init) { if (dcrtc->variant->init) {
ret = dcrtc->variant->init(dcrtc, dev); ret = dcrtc->variant->init(dcrtc, dev);
if (ret) { if (ret)
kfree(dcrtc); goto err_crtc;
return ret;
}
} }
/* Ensure AXI pipeline is enabled */ /* Ensure AXI pipeline is enabled */
...@@ -1203,13 +1199,15 @@ static int armada_drm_crtc_create(struct drm_device *drm, struct device *dev, ...@@ -1203,13 +1199,15 @@ static int armada_drm_crtc_create(struct drm_device *drm, struct device *dev,
dcrtc->crtc.port = port; dcrtc->crtc.port = port;
primary = kzalloc(sizeof(*primary), GFP_KERNEL); primary = kzalloc(sizeof(*primary), GFP_KERNEL);
if (!primary) if (!primary) {
return -ENOMEM; ret = -ENOMEM;
goto err_crtc;
}
ret = armada_drm_plane_init(primary); ret = armada_drm_plane_init(primary);
if (ret) { if (ret) {
kfree(primary); kfree(primary);
return ret; goto err_crtc;
} }
ret = drm_universal_plane_init(drm, &primary->base, 0, ret = drm_universal_plane_init(drm, &primary->base, 0,
...@@ -1219,7 +1217,7 @@ static int armada_drm_crtc_create(struct drm_device *drm, struct device *dev, ...@@ -1219,7 +1217,7 @@ static int armada_drm_crtc_create(struct drm_device *drm, struct device *dev,
DRM_PLANE_TYPE_PRIMARY); DRM_PLANE_TYPE_PRIMARY);
if (ret) { if (ret) {
kfree(primary); kfree(primary);
return ret; goto err_crtc;
} }
ret = drm_crtc_init_with_planes(drm, &dcrtc->crtc, &primary->base, NULL, ret = drm_crtc_init_with_planes(drm, &dcrtc->crtc, &primary->base, NULL,
...@@ -1238,6 +1236,9 @@ static int armada_drm_crtc_create(struct drm_device *drm, struct device *dev, ...@@ -1238,6 +1236,9 @@ static int armada_drm_crtc_create(struct drm_device *drm, struct device *dev,
err_crtc_init: err_crtc_init:
primary->base.funcs->destroy(&primary->base); primary->base.funcs->destroy(&primary->base);
err_crtc:
kfree(dcrtc);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment