Skip to content

Commit

Permalink
drm/i915: Defend against userspace creating a gem object with size==0
Browse files Browse the repository at this point in the history
We currently only round up the userspace size to the next page. We
assume that userspace hasn't made a mistake and requested a zero-length
gem object and all through our internal code we then presume that every
object is backed by at least a single page. Fix that oversight and
report EINVAL back to userspace if they try to create a zero length
object.

[danvet: This fixes tests/gem_bad_length]

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-Off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Ben Widawsky <ben@bwidawsk.net>
Signed-off-by: Keith Packard <keithp@keithp.com>
  • Loading branch information
Chris Wilson authored and Keith Packard committed Oct 20, 2011
1 parent 6dacfd2 commit 8ffc024
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/gpu/drm/i915/i915_gem.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ i915_gem_create(struct drm_file *file,
u32 handle;

size = roundup(size, PAGE_SIZE);
if (size == 0)
return -EINVAL;

/* Allocate the new object */
obj = i915_gem_alloc_object(dev, size);
Expand Down

0 comments on commit 8ffc024

Please sign in to comment.