All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] drm/ttm: check for NULL resource in ttm_bo_kmap()
@ 2026-11-09 20:23 kaii-k
  2026-11-09 20:23 ` [PATCH 2/3] drm/ttm: check for NULL resource in ttm_bo_vmap() kaii-k
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: kaii-k @ 2026-11-09 20:23 UTC (permalink / raw)
  To: nat, arunpravin.paneerselvam
  Cc: ckoenig, thomas.hellstrom, matthew.auld, matthew.brost, dri-devel,
	Harsh Parmar

From: Harsh Parmar <kaii02ctf@gmail.com>

A buffer object can legitimately have no backing store: a driver may
call ttm_bo_init_reserved() with zero placements, which leaves
bo->resource NULL. It can also become NULL after the backing store has
been released.

ttm_bo_kmap() dereferences bo->resource unconditionally (res->size),
causing a NULL pointer dereference and kernel oops when called on such a
buffer.

Bail out with -EINVAL if the buffer has no backing store.

Fixes: d3116756a710 ("drm/ttm: rename bo->mem and make it a pointer")
Signed-off-by: Harsh Parmar <kaii02ctf@gmail.com>
---
 drivers/gpu/drm/ttm/ttm_bo_util.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
index f9458a4..158f0df 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -435,6 +435,8 @@ int ttm_bo_kmap(struct ttm_buffer_object *bo,
 
 	map->virtual = NULL;
 	map->bo = bo;
+	if (!res)
+		return -EINVAL;
 	if (num_pages > PFN_UP(res->size))
 		return -EINVAL;
 	if ((start_page + num_pages) > PFN_UP(res->size))
-- 
2.53.0


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

end of thread, other threads:[~2026-11-10  9:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-09 20:23 [PATCH 1/3] drm/ttm: check for NULL resource in ttm_bo_kmap() kaii-k
2026-11-09 20:23 ` [PATCH 2/3] drm/ttm: check for NULL resource in ttm_bo_vmap() kaii-k
2026-11-09 20:23 ` [PATCH 3/3] drm/ttm: check for NULL resource in ttm_bo_vm_fault_reserved() kaii-k
2026-11-10  9:22   ` sashiko-bot
2026-11-10  8:58 ` [PATCH 1/3] drm/ttm: check for NULL resource in ttm_bo_kmap() sashiko-bot
2026-11-10  9:24 ` Christian König

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.