drm/i915/ttm: Fix access_memory null pointer exception
Subsystems (2)
PATCH 1/1 drm/i915/ttm: Fix access_memory null pointer exception
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.
--- drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_ttm.c +7 -2
@@ -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
Signature · 1 line
2.25.1
Patchwork
CI[igt-dev] ✗ Fi.CI.BUILD: failure for drm/i915/ttm: Fix access_memory null pointer exception
== Series Details ==
== Series Details ==
Series: drm/i915/ttm: Fix access_memory null pointer exception
URL : https://patchwork.freedesktop.org/series/109676/
State : failure
== Summary ==
Applying: drm/i915/ttm: Fix access_memory null pointer exception Patch failed at 0001 drm/i915/ttm: Fix access_memory null pointer exception When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort".
Quoted 1 line · Jonathan Cavitt
i915_ttm_to_gemcan return a NULL pointer,
ttm can pass non-i915 BOs but I keep forgetting where all ttm might
do that.
Thanks,
Nirmoy
Quoted 40 lines
which is
dereferenced ini915_ttm_access_memorywithout first checking if it is NULL. Inspectingi915_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 <[email protected]>Suggested-by John C Harrison <[email protected]>CC Matthew Auld <[email protected]>CC Andrzej Hajda <[email protected]>CC Nirmoy Das <[email protected]>CC Andi Shyti <[email protected]>--- drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)drivers/gpu/drm/i915/gem/i915_gem_ttm.c +7
-2@@ -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