[2/2] drm/plane-helper: Use init state when freshly allocating them
diff mbox

Message ID 1435845627-7287-2-git-send-email-daniel.vetter@ffwll.ch
State New
Headers show

Commit Message

Daniel Vetter July 2, 2015, 2 p.m. UTC
Daniel fixed the same issue for crtc states in

commit 9f658b7b62e7aefc1ee067136126eca3f58cabfd
Author: Daniel Stone <daniels@collabora.com>
Date:   Fri May 22 13:34:45 2015 +0100

    drm/crtc_helper: Replace open-coded CRTC state helpers

Follow suite.

Cc: Daniel Stone <daniels@collabora.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/drm_plane_helper.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Patch
diff mbox

diff --git a/drivers/gpu/drm/drm_plane_helper.c b/drivers/gpu/drm/drm_plane_helper.c
index 2f0ed11024eb..cd367dde7521 100644
--- a/drivers/gpu/drm/drm_plane_helper.c
+++ b/drivers/gpu/drm/drm_plane_helper.c
@@ -527,8 +527,11 @@  int drm_plane_helper_update(struct drm_plane *plane, struct drm_crtc *crtc,
 		plane_state = plane->funcs->atomic_duplicate_state(plane);
 	else if (plane->state)
 		plane_state = drm_atomic_helper_plane_duplicate_state(plane);
-	else
+	else {
 		plane_state = kzalloc(sizeof(*plane_state), GFP_KERNEL);
+		if (plane_state)
+			__drm_atomic_helper_plane_duplicate_state(plane, plane_state);
+	}
 	if (!plane_state)
 		return -ENOMEM;
 	plane_state->plane = plane;
@@ -574,8 +577,11 @@  int drm_plane_helper_disable(struct drm_plane *plane)
 		plane_state = plane->funcs->atomic_duplicate_state(plane);
 	else if (plane->state)
 		plane_state = drm_atomic_helper_plane_duplicate_state(plane);
-	else
+	else {
 		plane_state = kzalloc(sizeof(*plane_state), GFP_KERNEL);
+		if (plane_state)
+			__drm_atomic_helper_plane_duplicate_state(plane, plane_state);
+	}
 	if (!plane_state)
 		return -ENOMEM;
 	plane_state->plane = plane;