HW version 10 does not have GB Surfaces so there is no backing buffer for
surface backed FBs. This would result in a nullptr dereference and crash
the driver causing a black screen.

Fixes: 965544150d1c ("drm/vmwgfx: Refactor cursor handling")
Signed-off-by: Ian Forbes <[email protected]>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index 87448e86d3b3..4446f25e526d 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -767,13 +767,15 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct 
drm_device *dev,
                return ERR_PTR(ret);
        }
 
-       ttm_bo_reserve(&bo->tbo, false, false, NULL);
-       ret = vmw_bo_dirty_add(bo);
-       if (!ret && surface && surface->res.func->dirty_alloc) {
-               surface->res.coherent = true;
-               ret = surface->res.func->dirty_alloc(&surface->res);
+       if (bo) {
+               ttm_bo_reserve(&bo->tbo, false, false, NULL);
+               ret = vmw_bo_dirty_add(bo);
+               if (!ret && surface && surface->res.func->dirty_alloc) {
+                       surface->res.coherent = true;
+                       ret = surface->res.func->dirty_alloc(&surface->res);
+               }
+               ttm_bo_unreserve(&bo->tbo);
        }
-       ttm_bo_unreserve(&bo->tbo);
 
        return &vfb->base;
 }
-- 
2.51.1

Reply via email to