aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/i915_gem_tiling.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2011-02-19 06:31:06 -0500
committerChris Wilson <chris@chris-wilson.co.uk>2011-02-22 10:55:57 -0500
commitc87252266352c5201e2925740018f52578fa92bb (patch)
tree3fb6490ce2fb1c62d536bb256a727c07abef45e4 /drivers/gpu/drm/i915/i915_gem_tiling.c
parent548f245ba6a318ef93f4d79bcc15cfe59a86f0d5 (diff)
drm/i915: Protect against drm_gem_object not being the first member
Dave Airlie spotted that we had a potential bug should we ever rearrange the drm_i915_gem_object so not the base drm_gem_object was not its first member. He noticed that we often convert the return of drm_gem_object_lookup() immediately into drm_i915_gem_object and then check the result for nullity. This is only valid when the base object is the first member and so the superobject has the same address. Play safe instead and use the compiler to convert back to the original return address for sanity testing. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'drivers/gpu/drm/i915/i915_gem_tiling.c')
-rw-r--r--drivers/gpu/drm/i915/i915_gem_tiling.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/gpu/drm/i915/i915_gem_tiling.c b/drivers/gpu/drm/i915/i915_gem_tiling.c
index a093d67b94e2..0a8969392829 100644
--- a/drivers/gpu/drm/i915/i915_gem_tiling.c
+++ b/drivers/gpu/drm/i915/i915_gem_tiling.c
@@ -286,7 +286,7 @@ i915_gem_set_tiling(struct drm_device *dev, void *data,
286 struct drm_i915_gem_object *obj; 286 struct drm_i915_gem_object *obj;
287 287
288 obj = to_intel_bo(drm_gem_object_lookup(dev, file, args->handle)); 288 obj = to_intel_bo(drm_gem_object_lookup(dev, file, args->handle));
289 if (obj == NULL) 289 if (&obj->base == NULL)
290 return -ENOENT; 290 return -ENOENT;
291 291
292 if (!i915_tiling_ok(dev, 292 if (!i915_tiling_ok(dev,
@@ -366,7 +366,7 @@ i915_gem_get_tiling(struct drm_device *dev, void *data,
366 struct drm_i915_gem_object *obj; 366 struct drm_i915_gem_object *obj;
367 367
368 obj = to_intel_bo(drm_gem_object_lookup(dev, file, args->handle)); 368 obj = to_intel_bo(drm_gem_object_lookup(dev, file, args->handle));
369 if (obj == NULL) 369 if (&obj->base == NULL)
370 return -ENOENT; 370 return -ENOENT;
371 371
372 mutex_lock(&dev->struct_mutex); 372 mutex_lock(&dev->struct_mutex);