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 1/3] drm/ttm: check for NULL resource in ttm_bo_kmap()
Date: Tue, 10 Nov 2026 01:53:28 +0530	[thread overview]
Message-ID: <20261109202330.1816799-1-harshicon28@gmail.com> (raw)

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


             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 kaii-k [this message]
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

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-1-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.