All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH] drm/i915: Reorder phys backing storage release
Date: Wed, 07 Dec 2016 14:10:34 +0200	[thread overview]
Message-ID: <1481112634.5745.5.camel@linux.intel.com> (raw)
In-Reply-To: <20161207100755.8537-1-chris@chris-wilson.co.uk>

On ke, 2016-12-07 at 10:07 +0000, Chris Wilson wrote:
> In commit a4f5ea64f0a8 ("drm/i915: Refactor object page API"), I
> reordered the object->pages teardown to be more friendly wrt to a
> separate obj->mm.lock. However, I overlooked the phys object and left it
> with a dangling use-after-free of its phys_handle. Move the allocation
> of the phys handle to get_pages and it release to put_pages to prevent
> the invalid access and to improve symmetry.
> 
> Testcase: igt/drv_selftest/objects
> Reported-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Fixes: a4f5ea64f0a8 ("drm/i915: Refactor object page API")
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Cc: intel-gfx@lists.freedesktop.org

<SNIP>

>  i915_gem_object_get_pages_phys(struct drm_i915_gem_object *obj)
>  {
>  	struct address_space *mapping = obj->base.filp->f_mapping;
> -	char *vaddr = obj->phys_handle->vaddr;
> +	drm_dma_handle_t *phys;
>  	struct sg_table *st;
>  	struct scatterlist *sg;
> +	char *vaddr;
>  	int i;
>  
>  	if (WARN_ON(i915_gem_object_needs_bit17_swizzle(obj)))
>  		return ERR_PTR(-EINVAL);
>  
> +	phys = drm_pci_alloc(obj->base.dev, obj->base.size, obj->base.size);

Aligning to object size sounds bit rough without any comments.

> @@ -204,21 +212,29 @@ i915_gem_object_get_pages_phys(struct drm_i915_gem_object *obj)
>  	i915_gem_chipset_flush(to_i915(obj->base.dev));
>  
>  	st = kmalloc(sizeof(*st), GFP_KERNEL);
> -	if (st == NULL)
> -		return ERR_PTR(-ENOMEM);
> +	if (st == NULL) {

Could convert to (!st) when touching, pleases checkpatch.pl.

With the align propagated or explained in a comment;

Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>

Regards, Joonas
-- 
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2016-12-07 12:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-07 10:07 [PATCH] drm/i915: Reorder phys backing storage release Chris Wilson
2016-12-07 11:45 ` ✓ Fi.CI.BAT: success for " Patchwork
2016-12-07 12:10 ` Joonas Lahtinen [this message]
2016-12-07 12:27   ` [PATCH] " Chris Wilson
2016-12-07 13:56     ` Joonas Lahtinen

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=1481112634.5745.5.camel@linux.intel.com \
    --to=joonas.lahtinen@linux.intel.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.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.