drm/vmwgfx: Fix user space handle equal to zero
authorThomas Hellstrom <thellstrom@vmware.com>
Tue, 7 May 2019 09:10:10 +0000 (11:10 +0200)
committerThomas Hellstrom <thellstrom@vmware.com>
Tue, 21 May 2019 08:23:09 +0000 (10:23 +0200)
User-space handles equal to zero are interpreted as uninitialized or
illegal by some drm systems (most notably kms). This means that a
dumb buffer or surface with a zero user-space handle can never be
used as a kms frame-buffer.

Cc: <stable@vger.kernel.org>
Fixes: c7eae62666ad ("drm/vmwgfx: Make the object handles idr-generated")
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Deepak Rawat <drawat@vmware.com>
drivers/gpu/drm/vmwgfx/ttm_object.c

index 36990b8..1607778 100644 (file)
@@ -174,7 +174,7 @@ int ttm_base_object_init(struct ttm_object_file *tfile,
        kref_init(&base->refcount);
        idr_preload(GFP_KERNEL);
        spin_lock(&tdev->object_lock);
-       ret = idr_alloc(&tdev->idr, base, 0, 0, GFP_NOWAIT);
+       ret = idr_alloc(&tdev->idr, base, 1, 0, GFP_NOWAIT);
        spin_unlock(&tdev->object_lock);
        idr_preload_end();
        if (ret < 0)