mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/vmwgfx: Handle MOBs without page-table BOs
@ 2026-07-07 15:05 Ruoyu Wang
  2026-07-08  1:46 ` Maaz Mombasawala
  2026-07-08  3:35 ` Zack Rusin
  0 siblings, 2 replies; 3+ messages in thread
From: Ruoyu Wang @ 2026-07-07 15:05 UTC (permalink / raw)
  To: zack.rusin, bcm-kernel-feedback-list, maarten.lankhorst, mripard,
	tzimmermann, airlied, simona
  Cc: mombasawalam, krastevm, dri-devel, linux-kernel, Ruoyu Wang

Single-page MOBs and small OTable bases use depth-0 page-table entries
and do not allocate a page-table BO. Their existing teardown paths were
written to tolerate that by checking a local BO pointer before reserving
or fencing it.

Commit 668b206601c5 ("drm/vmwgfx: Stop using raw ttm_buffer_object's")
changed pt_bo from a raw TTM buffer object pointer to a vmwgfx BO pointer
and converted those local BO initializers to &pt_bo->tbo. That
dereferences pt_bo before the existing NULL checks, so depth-0 MOBs can
crash during OTable teardown or MOB unbind.

Keep the previous conditional behavior by deriving the TTM BO only when
the MOB has a page-table BO.

This issue was found by a static analysis checker and confirmed by
manual source review.

Fixes: 668b206601c5 ("drm/vmwgfx: Stop using raw ttm_buffer_object's")
Signed-off-by: Ruoyu Wang <ruoyuw560@gmail.com>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_mob.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_mob.c b/drivers/gpu/drm/vmwgfx/vmwgfx_mob.c
index de7a504de9ce5..7cfd96e6e3489 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_mob.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_mob.c
@@ -204,7 +204,9 @@ static void vmw_takedown_otable_base(struct vmw_private *dev_priv,
 	if (otable->page_table == NULL)
 		return;
 
-	bo = &otable->page_table->pt_bo->tbo;
+	bo = NULL;
+	if (otable->page_table->pt_bo)
+		bo = &otable->page_table->pt_bo->tbo;
 	cmd = VMW_CMD_RESERVE(dev_priv, sizeof(*cmd));
 	if (unlikely(cmd == NULL))
 		return;
@@ -555,7 +557,10 @@ void vmw_mob_unbind(struct vmw_private *dev_priv,
 		SVGA3dCmdDestroyGBMob body;
 	} *cmd;
 	int ret;
-	struct ttm_buffer_object *bo = &mob->pt_bo->tbo;
+	struct ttm_buffer_object *bo = NULL;
+
+	if (mob->pt_bo)
+		bo = &mob->pt_bo->tbo;
 
 	if (bo) {
 		ret = ttm_bo_reserve(bo, false, true, NULL);
-- 
2.51.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-07-08  3:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-07 15:05 [PATCH] drm/vmwgfx: Handle MOBs without page-table BOs Ruoyu Wang
2026-07-08  1:46 ` Maaz Mombasawala
2026-07-08  3:35 ` Zack Rusin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®