diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2010-10-27 12:37:08 -0400 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2010-10-27 18:31:08 -0400 |
commit | da761a6edf5c12ba2e7566c5e6bc98899d46ff12 (patch) | |
tree | 16bcf5df74fe6c4ff92dda6a6a773301491760c6 | |
parent | fb7d516af11837126eb1e4a44ab0653bf9b57702 (diff) |
drm/i915: Bail early if we try to mmap an object too large to be mapped.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | drivers/gpu/drm/i915/i915_gem.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 2eceb24bf54b..19ceb8cd0922 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c | |||
@@ -1258,6 +1258,7 @@ int | |||
1258 | i915_gem_mmap_ioctl(struct drm_device *dev, void *data, | 1258 | i915_gem_mmap_ioctl(struct drm_device *dev, void *data, |
1259 | struct drm_file *file_priv) | 1259 | struct drm_file *file_priv) |
1260 | { | 1260 | { |
1261 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
1261 | struct drm_i915_gem_mmap *args = data; | 1262 | struct drm_i915_gem_mmap *args = data; |
1262 | struct drm_gem_object *obj; | 1263 | struct drm_gem_object *obj; |
1263 | loff_t offset; | 1264 | loff_t offset; |
@@ -1270,6 +1271,11 @@ i915_gem_mmap_ioctl(struct drm_device *dev, void *data, | |||
1270 | if (obj == NULL) | 1271 | if (obj == NULL) |
1271 | return -ENOENT; | 1272 | return -ENOENT; |
1272 | 1273 | ||
1274 | if (obj->size > dev_priv->mm.gtt_mappable_end) { | ||
1275 | drm_gem_object_unreference_unlocked(obj); | ||
1276 | return -E2BIG; | ||
1277 | } | ||
1278 | |||
1273 | offset = args->offset; | 1279 | offset = args->offset; |
1274 | 1280 | ||
1275 | down_write(¤t->mm->mmap_sem); | 1281 | down_write(¤t->mm->mmap_sem); |
@@ -1547,6 +1553,7 @@ int | |||
1547 | i915_gem_mmap_gtt_ioctl(struct drm_device *dev, void *data, | 1553 | i915_gem_mmap_gtt_ioctl(struct drm_device *dev, void *data, |
1548 | struct drm_file *file_priv) | 1554 | struct drm_file *file_priv) |
1549 | { | 1555 | { |
1556 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
1550 | struct drm_i915_gem_mmap_gtt *args = data; | 1557 | struct drm_i915_gem_mmap_gtt *args = data; |
1551 | struct drm_gem_object *obj; | 1558 | struct drm_gem_object *obj; |
1552 | struct drm_i915_gem_object *obj_priv; | 1559 | struct drm_i915_gem_object *obj_priv; |
@@ -1566,6 +1573,11 @@ i915_gem_mmap_gtt_ioctl(struct drm_device *dev, void *data, | |||
1566 | } | 1573 | } |
1567 | obj_priv = to_intel_bo(obj); | 1574 | obj_priv = to_intel_bo(obj); |
1568 | 1575 | ||
1576 | if (obj->size > dev_priv->mm.gtt_mappable_end) { | ||
1577 | ret = -E2BIG; | ||
1578 | goto unlock; | ||
1579 | } | ||
1580 | |||
1569 | if (obj_priv->madv != I915_MADV_WILLNEED) { | 1581 | if (obj_priv->madv != I915_MADV_WILLNEED) { |
1570 | DRM_ERROR("Attempting to mmap a purgeable buffer\n"); | 1582 | DRM_ERROR("Attempting to mmap a purgeable buffer\n"); |
1571 | ret = -EINVAL; | 1583 | ret = -EINVAL; |