gpu/drm: Fix lock held when returning to user space. 82/200682/1
authorTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Thu, 10 Jan 2019 10:19:31 +0000 (19:19 +0900)
committerHoegeun Kwon <hoegeun.kwon@samsung.com>
Thu, 28 Feb 2019 06:22:51 +0000 (15:22 +0900)
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
[hoegeun.kwon: this patch from the mainline 4089e272ac61 and it has been
 modified to be able to backport linux-v4.14.]
Change-Id: Iaa0d6e104054abc11181c43bdb6283a8bd30eb19
Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
drivers/gpu/drm/drm_atomic.c
drivers/gpu/drm/drm_mode_object.c

index bb5cc15..8bb5088 100644 (file)
@@ -2247,12 +2247,11 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
                        (arg->flags & DRM_MODE_PAGE_FLIP_EVENT))
                return -EINVAL;
 
-       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;
        state->allow_modeset = !!(arg->flags & DRM_MODE_ATOMIC_ALLOW_MODESET);
 
index 1055533..4177ee2 100644 (file)
@@ -432,11 +432,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) {