Skip to content

Commit ce14ec2

Browse files
committed
drm/crtc-helper: Fixup error handling in drm_helper_crtc_mode_set
In commit 9f658b7 Author: Daniel Stone <daniels@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. v3: After some debugging with John we realized that the above patch from Daniel also accidentally removed the if (crtc_state) check. This is legal when transitioning to atomic, when the initial state reset isn't all wired up yet properly. Reinstate that check to fix the bug John has hit. Cc: Daniel Stone <daniels@collabora.com> CC: Sean Paul <seanpaul@chromium.org> Cc: John Hunter <zhaojunwang@pku.edu.cn> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> Reviewed-by: Daniel Stone <daniels@collabora.com> Reported-and-tested-by: John Hunter <zhaojunwang@pku.edu.cn> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
1 parent a9cc54e commit ce14ec2

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

drivers/gpu/drm/drm_crtc_helper.c

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -927,15 +927,13 @@ int drm_helper_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mod
927927

928928
if (crtc->funcs->atomic_duplicate_state)
929929
crtc_state = crtc->funcs->atomic_duplicate_state(crtc);
930-
else {
930+
else if (crtc->state)
931+
crtc_state = drm_atomic_helper_crtc_duplicate_state(crtc);
932+
else
931933
crtc_state = kzalloc(sizeof(*crtc_state), GFP_KERNEL);
932-
if (!crtc_state)
933-
return -ENOMEM;
934-
if (crtc->state)
935-
__drm_atomic_helper_crtc_duplicate_state(crtc, crtc_state);
936-
else
937-
crtc_state->crtc = crtc;
938-
}
934+
935+
if (!crtc_state)
936+
return -ENOMEM;
939937

940938
crtc_state->planes_changed = true;
941939
crtc_state->mode_changed = true;
@@ -957,11 +955,11 @@ int drm_helper_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mod
957955
ret = drm_helper_crtc_mode_set_base(crtc, x, y, old_fb);
958956

959957
out:
960-
if (crtc->funcs->atomic_destroy_state)
961-
crtc->funcs->atomic_destroy_state(crtc, crtc_state);
962-
else {
963-
__drm_atomic_helper_crtc_destroy_state(crtc, crtc_state);
964-
kfree(crtc_state);
958+
if (crtc_state) {
959+
if (crtc->funcs->atomic_destroy_state)
960+
crtc->funcs->atomic_destroy_state(crtc, crtc_state);
961+
else
962+
drm_atomic_helper_crtc_destroy_state(crtc, crtc_state);
965963
}
966964

967965
return ret;

0 commit comments

Comments
 (0)