Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Intel-gfx] [PATCH] drm/i915/ttm: Fix access_memory null pointer exception
@ 2022-10-13 17:56 Jonathan Cavitt
  2022-10-13 19:28 ` [Intel-gfx] ✓ Fi.CI.BAT: success for " Patchwork
                   ` (5 more replies)
  0 siblings, 6 replies; 15+ messages in thread
From: Jonathan Cavitt @ 2022-10-13 17:56 UTC (permalink / raw)
  To: intel-gfx; +Cc: jonathan.cavitt, matthew.auld, andrzej.hajda, nirmoy.das

i915_ttm_to_gem can return a NULL pointer, which is
dereferenced in i915_ttm_access_memory without first
checking if it is NULL.  Inspecting
i915_ttm_io_mem_reserve, it appears the correct
behavior in this case is to return -EINVAL.

Fixes: 26b15eb0 ("drm/i915/ttm: implement access_memory")
Signed-off-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
Suggested-by: John C Harrison <John.C.Harrison@intel.com>
CC: Matthew Auld <matthew.auld@intel.com>
CC: Andrzej Hajda <andrzej.hajda@intel.com>
CC: Nirmoy Das <nirmoy.das@intel.com>
CC: Andi Shyti <andi.shyti@linux.intel.com>
---
 drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
index d63f30efd631..b569624f2ed9 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
@@ -704,11 +704,16 @@ static int i915_ttm_access_memory(struct ttm_buffer_object *bo,
 				  int len, int write)
 {
 	struct drm_i915_gem_object *obj = i915_ttm_to_gem(bo);
-	resource_size_t iomap = obj->mm.region->iomap.base -
-		obj->mm.region->region.start;
+	resource_size_t iomap;
 	unsigned long page = offset >> PAGE_SHIFT;
 	unsigned long bytes_left = len;
 
+	if (!obj)
+		return -EINVAL;
+
+	iomap = obj->mm.region->iomap.base -
+		obj->mm.region->region.start;
+
 	/*
 	 * TODO: For now just let it fail if the resource is non-mappable,
 	 * otherwise we need to perform the memcpy from the gpu here, without
-- 
2.25.1


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

end of thread, other threads:[~2022-10-14 14:53 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-13 17:56 [Intel-gfx] [PATCH] drm/i915/ttm: Fix access_memory null pointer exception Jonathan Cavitt
2022-10-13 19:28 ` [Intel-gfx] ✓ Fi.CI.BAT: success for " Patchwork
2022-10-13 23:07 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
2022-10-14  8:39 ` [Intel-gfx] [PATCH] " Matthew Auld
2022-10-14  8:56   ` Andi Shyti
2022-10-14  9:44     ` Matthew Auld
2022-10-14 14:49       ` Andi Shyti
2022-10-14  9:27   ` Das, Nirmoy
2022-10-14 10:13     ` Matthew Auld
2022-10-14 10:38       ` Das, Nirmoy
2022-10-14 10:52         ` Matthew Auld
2022-10-14 10:56           ` Das, Nirmoy
2022-10-14  8:47 ` Andi Shyti
2022-10-14  9:02 ` Andrzej Hajda
2022-10-14  9:52 ` Tvrtko Ursulin

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