Re: [bug report] drm/i915: Small compaction of the engine init code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Dec 15, 2016 at 11:44:13PM +0300, Dan Carpenter wrote:
> Hello Tvrtko Ursulin,
> 
> The patch a19d6ff29a82: "drm/i915: Small compaction of the engine
> init code" from Jun 23, 2016, leads to the following static checker
> warning:
> 
> 	drivers/gpu/drm/i915/intel_lrc.c:1973 logical_render_ring_init()
> 	warn: passing freed memory 'engine'
> 
> drivers/gpu/drm/i915/intel_lrc.c
>   1970  
>   1971          ret = logical_ring_init(engine);
>   1972          if (ret) {
>   1973                  lrc_destroy_wa_ctx_obj(engine);
> 
> The problem is that logical_ring_init() frees "engine" on the error
> path so this is a use after free.

And calls lrc_destroy_wa_ctx_obj() in the process. So we can

diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index 067394b0a769..1c1bad8ae7b0 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -1940,12 +1940,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)

-- 
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux