In

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

    drm/crtc_helper: Replace open-coded CRTC state helpers

error handling code was broken, resulting in the first path not being
checked correctly. Fix this by using the same pattern as in the
transitional plane helper function drm_plane_helper_update.

v2: Simplify the cleanup code while at it too.

Cc: Daniel Stone <daniels at collabora.com>
CC: Sean Paul <seanpaul at chromium.org>
Cc: John Hunter <zhaojunwang at pku.edu.cn>
Signed-off-by: Daniel Vetter <daniel.vetter at intel.com>
---
 drivers/gpu/drm/drm_crtc_helper.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/drm_crtc_helper.c 
b/drivers/gpu/drm/drm_crtc_helper.c
index 393114df88a3..f36750077c12 100644
--- a/drivers/gpu/drm/drm_crtc_helper.c
+++ b/drivers/gpu/drm/drm_crtc_helper.c
@@ -927,15 +927,13 @@ int drm_helper_crtc_mode_set(struct drm_crtc *crtc, 
struct drm_display_mode *mod

        if (crtc->funcs->atomic_duplicate_state)
                crtc_state = crtc->funcs->atomic_duplicate_state(crtc);
-       else {
+       else if (crtc->state)
+               crtc_state = drm_atomic_helper_crtc_duplicate_state(crtc);
+       else
                crtc_state = kzalloc(sizeof(*crtc_state), GFP_KERNEL);
-               if (!crtc_state)
-                       return -ENOMEM;
-               if (crtc->state)
-                       __drm_atomic_helper_crtc_duplicate_state(crtc, 
crtc_state);
-               else
-                       crtc_state->crtc = crtc;
-       }
+
+       if (!crtc_state)
+               return -ENOMEM;

        crtc_state->planes_changed = true;
        crtc_state->mode_changed = true;
@@ -959,10 +957,8 @@ int drm_helper_crtc_mode_set(struct drm_crtc *crtc, struct 
drm_display_mode *mod
 out:
        if (crtc->funcs->atomic_destroy_state)
                crtc->funcs->atomic_destroy_state(crtc, crtc_state);
-       else {
-               __drm_atomic_helper_crtc_destroy_state(crtc, crtc_state);
-               kfree(crtc_state);
-       }
+       else
+               drm_atomic_helper_crtc_destroy_state(crtc, crtc_state);

        return ret;
 }
-- 
2.1.4

Reply via email to