Skip to content

Commit

Permalink
drm/i915: Kill drop_pages()
Browse files Browse the repository at this point in the history
The drop_pages() function is a dangerous trap in that it can release the
passed in object pointer and so unless the caller is aware, it can
easily trick us into using the stale object afterwards. Move it into its
solitary callsite where we know it is safe.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1470293567-10811-9-git-send-email-chris@chris-wilson.co.uk
  • Loading branch information
Chris Wilson committed Aug 4, 2016
1 parent aa653a6 commit 4717ca9
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions drivers/gpu/drm/i915/i915_gem.c
Original file line number Diff line number Diff line change
@@ -306,20 +306,6 @@ i915_gem_object_unbind(struct drm_i915_gem_object *obj)
return ret;
}

static int
drop_pages(struct drm_i915_gem_object *obj)
{
int ret;

i915_gem_object_get(obj);
ret = i915_gem_object_unbind(obj);
if (ret == 0)
ret = i915_gem_object_put_pages(obj);
i915_gem_object_put(obj);

return ret;
}

int
i915_gem_object_attach_phys(struct drm_i915_gem_object *obj,
int align)
@@ -340,7 +326,11 @@ i915_gem_object_attach_phys(struct drm_i915_gem_object *obj,
if (obj->base.filp == NULL)
return -EINVAL;

ret = drop_pages(obj);
ret = i915_gem_object_unbind(obj);
if (ret)
return ret;

ret = i915_gem_object_put_pages(obj);
if (ret)
return ret;

0 comments on commit 4717ca9

Please sign in to comment.