From: Chris Wilson Date: Sat, 11 Aug 2012 14:41:05 +0000 (+0100) Subject: drm/i915: Protect private gem objects from truncate (such as imported dmabuf) X-Git-Tag: v3.7-rc1~118^2~30^2~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4d6294bf77834276d41b51154a18663b0a8f2063;p=platform%2Fkernel%2Flinux-3.10.git drm/i915: Protect private gem objects from truncate (such as imported dmabuf) If the object has no backing shmemfs filp, then we obviously cannot perform a truncation operation upon it. Signed-off-by: Chris Wilson Signed-off-by: Daniel Vetter --- diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 1ec5f7e..eb54a6d 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -1385,6 +1385,11 @@ i915_gem_object_truncate(struct drm_i915_gem_object *obj) { struct inode *inode; + i915_gem_object_free_mmap_offset(obj); + + if (obj->base.filp == NULL) + return; + /* Our goal here is to return as much of the memory as * is possible back to the system as we are called from OOM. * To do this we must instruct the shmfs to drop all of its @@ -1393,8 +1398,6 @@ i915_gem_object_truncate(struct drm_i915_gem_object *obj) inode = obj->base.filp->f_path.dentry->d_inode; shmem_truncate_range(inode, 0, (loff_t)-1); - i915_gem_object_free_mmap_offset(obj); - obj->madv = __I915_MADV_PURGED; }