From: Imre Deak <imre.deak@intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: intel-gfx@lists.freedesktop.org,
Daniel Vetter <daniel.vetter@ffwll.ch>,
Jani Nikula <jani.nikula@intel.com>,
stable@vger.kernel.org
Subject: Re: [PATCH v3 1/2] drm/i915: avoid leaking DMA mappings
Date: Mon, 13 Jul 2015 15:15:05 +0300 [thread overview]
Message-ID: <1436789705.16551.6.camel@intel.com> (raw)
In-Reply-To: <20150711205435.GM21656@nuc-i3427.alporthouse.com>
On la, 2015-07-11 at 21:54 +0100, Chris Wilson wrote:
> On Thu, Jul 09, 2015 at 12:59:05PM +0300, Imre Deak wrote:
> > +static int
> > +__i915_gem_userptr_set_pages(struct drm_i915_gem_object *obj,
> > + struct page **pvec, int num_pages)
> > +{
> > + int ret;
> > +
> > + ret = st_set_pages(&obj->pages, pvec, num_pages);
> > + if (ret)
> > + return ret;
> > +
> > + ret = i915_gem_gtt_prepare_object(obj);
> > + if (ret) {
> > + sg_free_table(obj->pages);
> > + kfree(obj->pages);
> > + obj->pages = NULL;
>
> Oh dear, we just leaked a ref one each page.
To summarize the IRC discussion on this: it would be logical that
sg_set_page() takes a ref - and in that case this would result in
leaking those refs - but this is not so. Instead we rely on the GUP refs
which we keep in case of success by setting pinned=0 (release_pages will
be a nop) and drop in case of failure by passing the original pinned
value to release_pages(). So after checking both the sync and async
userptr paths this looks ok to me.
--Imre
next prev parent reply other threads:[~2015-07-13 12:15 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-06 14:50 [PATCH] drm/i915: avoid leaking DMA mappings Imre Deak
2015-07-06 14:57 ` Chris Wilson
2015-07-06 15:11 ` Imre Deak
2015-07-06 15:28 ` Chris Wilson
2015-07-06 15:31 ` Imre Deak
2015-07-06 15:29 ` Daniel Vetter
2015-07-06 15:30 ` Imre Deak
2015-07-06 15:33 ` Chris Wilson
2015-07-06 15:56 ` Imre Deak
2015-07-06 16:04 ` Chris Wilson
2015-07-06 16:23 ` Imre Deak
2015-07-06 15:11 ` Tvrtko Ursulin
2015-07-06 15:21 ` Imre Deak
2015-07-07 19:09 ` shuang.he
2015-07-08 16:18 ` [PATCH v2 1/2] " Imre Deak
2015-07-08 17:19 ` Chris Wilson
2015-07-09 9:59 ` [PATCH v3 " Imre Deak
2015-07-09 9:59 ` Imre Deak
2015-07-09 10:04 ` Chris Wilson
2015-07-11 20:54 ` Chris Wilson
2015-07-13 12:15 ` Imre Deak [this message]
2015-07-08 16:18 ` [PATCH 2/2] drm/i915: remove unused has_dma_mapping flag Imre Deak
2015-07-08 17:43 ` Chris Wilson
2015-07-13 14:46 ` Daniel Vetter
2015-07-09 0:07 ` shuang.he
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=1436789705.16551.6.camel@intel.com \
--to=imre.deak@intel.com \
--cc=chris@chris-wilson.co.uk \
--cc=daniel.vetter@ffwll.ch \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@intel.com \
--cc=stable@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.