drm/i915/gem: Fix oops in error handling code
Subsystems (3)
PATCH 1/1 drm/i915/gem: Fix oops in error handling code
This code will Oops when it tries to i915_gem_object_free(obj) because "obj" is an error pointer.
--- drivers/gpu/drm/i915/gem/i915_gem_stolen.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_stolen.c +4 -8
@@ -753,22 +753,18 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_i915_private *i915,mutex_lock (&i915->mm.stolen_lock); ret =drm_mm_reserve_node (&i915->mm.stolen, stolen);mutex_unlock (&i915->mm.stolen_lock); -if (ret) { - obj =ERR_PTR (ret); +if (ret) goto err_free; - } obj =i915_gem_object_alloc ();if (!obj) { - obj =ERR_PTR (-ENOMEM ); + ret = -ENOMEM ; goto err_stolen; } ret =__i915_gem_object_create_stolen (mem, obj, stolen); -if (ret) { - obj =ERR_PTR (ret); +if (ret) goto err_object_free; - }i915_gem_object_set_cache_coherency (obj,I915_CACHE_NONE );return obj;
@@ -779,7 +775,7 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_i915_private *i915,i915_gem_stolen_remove_node (i915, stolen); err_free:kfree (stolen); -return obj; +return ERR_PTR (ret); }bool i915_gem_object_is_stolen (const struct drm_i915_gem_object *obj)
Signature · 1 line
2.29.2
Quoting Dan Carpenter (2021-01-25 08:47:12)
Quoted 5 lines
This code will Oops when it tries to
i915_gem_object_free(obj)because "obj" is an error pointer.Fixes 97d553963250 ("drm/i915/region: convert object_create into object_init")Signed-off-by Dan Carpenter <[email protected]>
It will indeed. On the preallocated path, so only during modprobe so unlikely but also fatal bsod. It would also take brute force selftest to generate the error, but as that doesn't serve any other purpose, leave it to static analysis.
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI[Intel-gfx] ✗ Fi.CI.BAT: failure for drm/i915/gem: Fix oops in error handling code
In reply to Dan Carpenter== Series Details ==
== Series Details ==
Series: drm/i915/gem: Fix oops in error handling code
URL : https://patchwork.freedesktop.org/series/86249/
State : failure
== Summary ==
Applying: drm/i915/gem: Fix oops in error handling code Using index info to reconstruct a base tree...
M drivers/gpu/drm/i915/gem/i915_gem_stolen.c
Falling back to patching base and 3-way merge... No changes -- Patch already applied.
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx