drm/i915: Protect against drm_gem_object not being the first member
authorChris Wilson <chris@chris-wilson.co.uk>
Sat, 19 Feb 2011 11:31:06 +0000 (11:31 +0000)
committerChris Wilson <chris@chris-wilson.co.uk>
Tue, 22 Feb 2011 15:55:57 +0000 (15:55 +0000)
commitc87252266352c5201e2925740018f52578fa92bb
tree3fb6490ce2fb1c62d536bb256a727c07abef45e4
parent548f245ba6a318ef93f4d79bcc15cfe59a86f0d5
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>
drivers/gpu/drm/i915/i915_gem.c
drivers/gpu/drm/i915/i915_gem_execbuffer.c
drivers/gpu/drm/i915/i915_gem_tiling.c
drivers/gpu/drm/i915/intel_display.c
drivers/gpu/drm/i915/intel_overlay.c