drm/i915: Take ownership of atomic state on success in intel_set_mode()
authorAnder Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
Tue, 21 Apr 2015 14:13:20 +0000 (17:13 +0300)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Fri, 8 May 2015 11:04:09 +0000 (13:04 +0200)
To match the behavior of ->atomic_commit().

Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/intel_display.c

index db450772b4a52f135c126a2bf5e5a466506ead41..e3e4a04a18bfa7bc70718782f914a8059d2d0d92 100644 (file)
@@ -9968,9 +9968,9 @@ void intel_release_load_detect_pipe(struct drm_connector *connector,
                if (ret)
                        goto fail;
 
-               intel_set_mode(crtc, state);
-
-               drm_atomic_state_free(state);
+               ret = intel_set_mode(crtc, state);
+               if (ret)
+                       goto fail;
 
                if (old->release_fb) {
                        drm_framebuffer_unregister_private(old->release_fb);
@@ -12425,6 +12425,8 @@ static int __intel_set_mode(struct drm_crtc *modeset_crtc,
        intel_crtc->config = crtc_state_copy;
        intel_crtc->base.state = &crtc_state_copy->base;
 
+       drm_atomic_state_free(state);
+
        return 0;
 }
 
@@ -12470,6 +12472,7 @@ void intel_crtc_restore_mode(struct drm_crtc *crtc)
        struct intel_connector *connector;
        struct drm_connector_state *connector_state;
        struct intel_crtc_state *crtc_state;
+       int ret;
 
        state = drm_atomic_state_alloc(dev);
        if (!state) {
@@ -12528,9 +12531,9 @@ void intel_crtc_restore_mode(struct drm_crtc *crtc)
        intel_modeset_setup_plane_state(state, crtc, &crtc->mode,
                                        crtc->primary->fb, crtc->x, crtc->y);
 
-       intel_set_mode(crtc, state);
-
-       drm_atomic_state_free(state);
+       ret = intel_set_mode(crtc, state);
+       if (ret)
+               drm_atomic_state_free(state);
 }
 
 #undef for_each_intel_crtc_masked
@@ -12759,7 +12762,8 @@ static int intel_crtc_set_config(struct drm_mode_set *set)
        }
 
 out:
-       drm_atomic_state_free(state);
+       if (ret)
+               drm_atomic_state_free(state);
        return ret;
 }