Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm: Move drm_mode_setcrtc() local re-init to failure path

Instead of always re-initializing the variables we need to clean up on
out, move the re-initialization into the branch that goes back to retry
label.

This is a lateral move right now, but will allow us to pull out the
modeset locking into common code. I kept this change separate to make
things easier to review.

Changes in v2:
- None

Reviewed-by: Daniel Vetter <daniel@ffwll.ch>
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20181129150423.239081-2-sean@poorly.run

+9 -7
+9 -7
drivers/gpu/drm/drm_crtc.c
··· 570 570 struct drm_mode_crtc *crtc_req = data; 571 571 struct drm_crtc *crtc; 572 572 struct drm_plane *plane; 573 - struct drm_connector **connector_set, *connector; 574 - struct drm_framebuffer *fb; 575 - struct drm_display_mode *mode; 573 + struct drm_connector **connector_set = NULL, *connector; 574 + struct drm_framebuffer *fb = NULL; 575 + struct drm_display_mode *mode = NULL; 576 576 struct drm_mode_set set; 577 577 uint32_t __user *set_connectors_ptr; 578 578 struct drm_modeset_acquire_ctx ctx; ··· 601 601 mutex_lock(&crtc->dev->mode_config.mutex); 602 602 drm_modeset_acquire_init(&ctx, DRM_MODESET_ACQUIRE_INTERRUPTIBLE); 603 603 retry: 604 - connector_set = NULL; 605 - fb = NULL; 606 - mode = NULL; 607 - 608 604 ret = drm_modeset_lock_all_ctx(crtc->dev, &ctx); 609 605 if (ret) 610 606 goto out; ··· 762 766 } 763 767 kfree(connector_set); 764 768 drm_mode_destroy(dev, mode); 769 + 770 + /* In case we need to retry... */ 771 + connector_set = NULL; 772 + fb = NULL; 773 + mode = NULL; 774 + 765 775 if (ret == -EDEADLK) { 766 776 ret = drm_modeset_backoff(&ctx); 767 777 if (!ret)