public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>,
	Dan Carpenter <dan.carpenter@oracle.com>,
	Tvrtko Ursulin <tvrtko.ursulin@intel.com>,
	intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [Intel-gfx] [bug report] drm/i915: Small compaction of the engine init code
Date: Fri, 16 Dec 2016 08:02:27 +0000	[thread overview]
Message-ID: <e240b36c-d585-349f-8ab3-83b85f6b3b3a@linux.intel.com> (raw)
In-Reply-To: <20161215205448.GM29871@nuc-i3427.alporthouse.com>


On 15/12/2016 20:54, Chris Wilson wrote:
> 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)
>

I've marked this as TODO for later.

Interesting that it was detected only now. Even more so, the referenced 
commit just moved the code around.

I think that the real issue was introduced around "drm/i915/gen8: 
Re-order init pipe_control in lrc mode".

Regards,

Tvrtko

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2016-12-16  8:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-15 20:44 [bug report] drm/i915: Small compaction of the engine init code Dan Carpenter
2016-12-15 20:54 ` Chris Wilson
2016-12-16  8:02   ` Tvrtko Ursulin [this message]
2016-12-16  8:38     ` [Intel-gfx] " Tvrtko Ursulin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e240b36c-d585-349f-8ab3-83b85f6b3b3a@linux.intel.com \
    --to=tvrtko.ursulin@linux.intel.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=dan.carpenter@oracle.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=tvrtko.ursulin@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox