All of lore.kernel.org
 help / color / mirror / Atom feed
From: kaii-k <harshicon28@gmail.com>
To: nat@pixelcluster.dev, arunpravin.paneerselvam@amd.com
Cc: ckoenig@amd.com, thomas.hellstrom@linux.intel.com,
	matthew.auld@intel.com, matthew.brost@intel.com,
	dri-devel@lists.freedesktop.org,
	Harsh Parmar <kaii02ctf@gmail.com>
Subject: [PATCH 3/3] drm/ttm: check for NULL resource in ttm_bo_vm_fault_reserved()
Date: Tue, 10 Nov 2026 01:53:30 +0530	[thread overview]
Message-ID: <20261109202330.1816799-3-harshicon28@gmail.com> (raw)
In-Reply-To: <20261109202330.1816799-1-harshicon28@gmail.com>

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_vm_fault_reserved() passes bo->resource to ttm_mem_io_reserve()
and dereferences it, causing a NULL pointer dereference when a fault hits
a buffer with no backing store.

Return VM_FAULT_SIGBUS 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_vm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
index 872bf44..69dd6bd 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
@@ -205,6 +205,9 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf,
 	if (unlikely(ret != 0))
 		return ret;
 
+	if (unlikely(!bo->resource))
+		return VM_FAULT_SIGBUS;
+
 	err = ttm_mem_io_reserve(bo->bdev, bo->resource);
 	if (unlikely(err != 0))
 		return VM_FAULT_SIGBUS;
-- 
2.53.0


  parent reply	other threads:[~2026-11-10  8:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` kaii-k [this message]
2026-11-10  9:22   ` [PATCH 3/3] drm/ttm: check for NULL resource in ttm_bo_vm_fault_reserved() 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261109202330.1816799-3-harshicon28@gmail.com \
    --to=harshicon28@gmail.com \
    --cc=arunpravin.paneerselvam@amd.com \
    --cc=ckoenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kaii02ctf@gmail.com \
    --cc=matthew.auld@intel.com \
    --cc=matthew.brost@intel.com \
    --cc=nat@pixelcluster.dev \
    --cc=thomas.hellstrom@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.