From: Chris Wilson Date: Wed, 2 Jan 2013 10:31:22 +0000 (+0000) Subject: drm/i915; Only increment the user-pin-count after successfully pinning the bo X-Git-Tag: v3.4.92~54 X-Git-Url: https://git.fsl.cs.sunysb.edu/?a=commitdiff_plain;h=5fbe150df29254ba07b42834d582689c80a00f08;p=unionfs-2.6.18.y.git drm/i915; Only increment the user-pin-count after successfully pinning the bo commit 93be8788e648817d62fda33e2998eb6ca6ebf3a3 upstream. As along the error path we do not correct the user pin-count for the failure, we may end up with userspace believing that it has a pinned object at offset 0 (when interrupted by a signal for example). Signed-off-by: Chris Wilson Signed-off-by: Daniel Vetter [bwh: Backported to 3.2: adjust context] Signed-off-by: Ben Hutchings Cc: Weng Meiling Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index eb339456c11..a0fa218e972 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -3411,14 +3411,15 @@ i915_gem_pin_ioctl(struct drm_device *dev, void *data, goto out; } - obj->user_pin_count++; - obj->pin_filp = file; - if (obj->user_pin_count == 1) { + if (obj->user_pin_count == 0) { ret = i915_gem_object_pin(obj, args->alignment, true); if (ret) goto out; } + obj->user_pin_count++; + obj->pin_filp = file; + /* XXX - flush the CPU caches for pinned objects * as the X server doesn't manage domains yet */