gpu/drm: Fix lock held when returning to user space.
authorTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Thu, 10 Jan 2019 10:19:31 +0000 (19:19 +0900)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Thu, 10 Jan 2019 10:31:58 +0000 (11:31 +0100)
We need to call drm_modeset_acquire_fini() when drm_atomic_state_alloc()
failed or call drm_modeset_acquire_init() after drm_atomic_state_alloc()
succeeded.

Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Reported-by: syzbot <syzbot+6ea337c427f5083ebdf2@syzkaller.appspotmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/1547115571-21219-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp
drivers/gpu/drm/drm_atomic_uapi.c
drivers/gpu/drm/drm_mode_object.c

index c40889888a16bccc0cf44591130fdf3872292ab5..9a1f41adfc674db010ecb365d7a9ee856945bb6b 100644 (file)
@@ -1296,12 +1296,11 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
                        (arg->flags & DRM_MODE_PAGE_FLIP_EVENT))
                return -EINVAL;
 
-       drm_modeset_acquire_init(&ctx, DRM_MODESET_ACQUIRE_INTERRUPTIBLE);
-
        state = drm_atomic_state_alloc(dev);
        if (!state)
                return -ENOMEM;
 
+       drm_modeset_acquire_init(&ctx, DRM_MODESET_ACQUIRE_INTERRUPTIBLE);
        state->acquire_ctx = &ctx;
        state->allow_modeset = !!(arg->flags & DRM_MODE_ATOMIC_ALLOW_MODESET);
 
index cd9bc0ce9be07bfc3169ddf5596184f3991e5bc6..004191d0177221f06c2b5f56e49f63b3c9d49746 100644 (file)
@@ -459,11 +459,11 @@ static int set_property_atomic(struct drm_mode_object *obj,
        struct drm_modeset_acquire_ctx ctx;
        int ret;
 
-       drm_modeset_acquire_init(&ctx, 0);
-
        state = drm_atomic_state_alloc(dev);
        if (!state)
                return -ENOMEM;
+
+       drm_modeset_acquire_init(&ctx, 0);
        state->acquire_ctx = &ctx;
 retry:
        if (prop == state->dev->mode_config.dpms_property) {