drm/i915: Fix use after free in logical_render_ring_init
authorTvrtko Ursulin <[email protected]>
Fri, 16 Dec 2016 13:18:42 +0000 (13:18 +0000)
committerJani Nikula <[email protected]>
Tue, 20 Dec 2016 14:30:27 +0000 (16:30 +0200)
Commit 3b3f1650b1ca ("drm/i915: Allocate intel_engine_cs
structure only for the enabled engines") introduced the
dynanically allocated engine instances and created an
potential use after free scenario in logical_render_ring_init
where lrc_destroy_wa_ctx_obj could be called after the engine
instance has been freed.

This can only happen during engine setup/init error handling
which luckily does not happen ever in practice.

Fix is to not call lrc_destroy_wa_ctx_obj since it would have
already been executed from the preceding engine cleanup.

Signed-off-by: Tvrtko Ursulin <[email protected]>
Reported-by: Dan Carpenter <[email protected]>
Fixes: 3b3f1650b1ca ("drm/i915: Allocate intel_engine_cs structure only for the enabled engines")
Cc: Chris Wilson <[email protected]>
Cc: Joonas Lahtinen <[email protected]>
Cc: Tvrtko Ursulin <[email protected]>
Cc: Daniel Vetter <[email protected]>
Cc: Jani Nikula <[email protected]>
Reviewed-by: Chris Wilson <[email protected]>
Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
(cherry picked from commit d038fc7e4fff14d6b026130007faef35cbf5e956)
Signed-off-by: Jani Nikula <[email protected]>
drivers/gpu/drm/i915/intel_lrc.c

index 0a09024d6ca3ebc502f0b99cef07ed91f0b4cd64..d4961fa20c73d0e2d390673889ae5fa82f04dd07 100644 (file)
@@ -1968,12 +1968,7 @@ int logical_render_ring_init(struct intel_engine_cs *engine)
                          ret);
        }
 
-       ret = logical_ring_init(engine);
-       if (ret) {
-               lrc_destroy_wa_ctx_obj(engine);
-       }
-
-       return ret;
+       return logical_ring_init(engine);
 }
 
 int logical_xcs_ring_init(struct intel_engine_cs *engine)