Skip to content

Commit f17cc0f

Browse files
Dan Carpenterrodrigovivi
authored andcommitted
drm/i915/gt: Prevent error pointer dereference
Move the check for "if (IS_ERR(obj))" in front of the call to i915_gem_object_set_cache_coherency() which dereferences "obj". Otherwise it will lead to a crash. Fixes: 43aa755 ("drm/i915/mtl: Update cache coherency setting for context structure") Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com> Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/455b2279-2e08-4d00-9784-be56d8ee42e3@moroto.mountain (cherry picked from commit c92ec50) Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
1 parent ce9ecca commit f17cc0f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/gpu/drm/i915/gt/intel_lrc.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,6 +1094,9 @@ __lrc_alloc_state(struct intel_context *ce, struct intel_engine_cs *engine)
10941094
I915_BO_ALLOC_PM_VOLATILE);
10951095
if (IS_ERR(obj)) {
10961096
obj = i915_gem_object_create_shmem(engine->i915, context_size);
1097+
if (IS_ERR(obj))
1098+
return ERR_CAST(obj);
1099+
10971100
/*
10981101
* Wa_22016122933: For Media version 13.0, all Media GT shared
10991102
* memory needs to be mapped as WC on CPU side and UC (PAT
@@ -1102,8 +1105,6 @@ __lrc_alloc_state(struct intel_context *ce, struct intel_engine_cs *engine)
11021105
if (intel_gt_needs_wa_22016122933(engine->gt))
11031106
i915_gem_object_set_cache_coherency(obj, I915_CACHE_NONE);
11041107
}
1105-
if (IS_ERR(obj))
1106-
return ERR_CAST(obj);
11071108

11081109
vma = i915_vma_instance(obj, &engine->gt->ggtt->vm, NULL);
11091110
if (IS_ERR(vma)) {

0 commit comments

Comments
 (0)