Skip to content

Commit b6c7335

Browse files
atseanpaulSasha Levin
authored and
Sasha Levin
committed
drm: Move drm_mode_setcrtc() local re-init to failure path
[ Upstream commit c232e9f ] 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 <[email protected]> Signed-off-by: Sean Paul <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Stable-dep-of: b6802b6 ("drm/crtc: fix uninitialized variable use even harder") Signed-off-by: Sasha Levin <[email protected]>
1 parent 698daa5 commit b6c7335

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

drivers/gpu/drm/drm_crtc.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -567,9 +567,9 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
567567
struct drm_mode_crtc *crtc_req = data;
568568
struct drm_crtc *crtc;
569569
struct drm_plane *plane;
570-
struct drm_connector **connector_set, *connector;
571-
struct drm_framebuffer *fb;
572-
struct drm_display_mode *mode;
570+
struct drm_connector **connector_set = NULL, *connector;
571+
struct drm_framebuffer *fb = NULL;
572+
struct drm_display_mode *mode = NULL;
573573
struct drm_mode_set set;
574574
uint32_t __user *set_connectors_ptr;
575575
struct drm_modeset_acquire_ctx ctx;
@@ -601,10 +601,6 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
601601
mutex_lock(&crtc->dev->mode_config.mutex);
602602
drm_modeset_acquire_init(&ctx, DRM_MODESET_ACQUIRE_INTERRUPTIBLE);
603603
retry:
604-
connector_set = NULL;
605-
fb = NULL;
606-
mode = NULL;
607-
608604
ret = drm_modeset_lock_all_ctx(crtc->dev, &ctx);
609605
if (ret)
610606
goto out;
@@ -767,6 +763,12 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
767763
}
768764
kfree(connector_set);
769765
drm_mode_destroy(dev, mode);
766+
767+
/* In case we need to retry... */
768+
connector_set = NULL;
769+
fb = NULL;
770+
mode = NULL;
771+
770772
if (ret == -EDEADLK) {
771773
ret = drm_modeset_backoff(&ctx);
772774
if (!ret)

0 commit comments

Comments
 (0)