Skip to contentSkip to conversation

drm/i915: check gem bo size when creating framebuffers

PATCH In review Daniel Vetter 2 participants 2 messages Oct 9, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/i915: check gem bo size when creating framebuffers

It's better to catch such fallout early, and this way we can rely on the checking done by the drm core on fb->heigh/width at modeset time.

If we ever support planar formats on intel we might want to look into a common helper to do all this, but for now this is good enough.

---
 drivers/gpu/drm/i915/intel_display.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/i915/intel_display.c +4 -0
index f5126b8..3073154 100644
@@ -10069,6 +10069,10 @@ int intel_framebuffer_init(struct drm_device *dev,
 	if (mode_cmd->offsets[0] != 0)
 		return -EINVAL;
 
+	/* FIXME drm helper for size checks (especially planar formats)? */
+	if (obj->base.size < mode_cmd->height * mode_cmd->pitches[0])
+		return -EINVAL;
+
 	drm_helper_mode_fill_fb_struct(&intel_fb->base, mode_cmd);
 	intel_fb->obj = obj;
 
Signature · 1 line
1.8.4.rc3
#1 lore raw
Quoted 5 lines · Daniel Vetter

It's better to catch such fallout early, and this way we can rely on the checking done by the drm core on fb->heigh/width at modeset time.

If we ever support planar formats on intel we might want to look into a common helper to do all this, but for now this is good enough.

I had a helper to do that, and I think I even posted it a few times. But it didn't take tiling into account, so I didn't feel it was quite good enough. I think this may be the last one:
http://lists.freedesktop.org/archives/dri-devel/2011-December/017581.html

Your patch doesn't account for tiling either.

Quoted 30 lines
---
 drivers/gpu/drm/i915/intel_display.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/i915/intel_display.c +4 -0
index f5126b8..3073154 100644
@@ -10069,6 +10069,10 @@ int intel_framebuffer_init(struct drm_device *dev,
 	if (mode_cmd->offsets[0] != 0)
 		return -EINVAL;
 
+	/* FIXME drm helper for size checks (especially planar formats)? */
+	if (obj->base.size < mode_cmd->height * mode_cmd->pitches[0])
+		return -EINVAL;
+
 	drm_helper_mode_fill_fb_struct(&intel_fb->base, mode_cmd);
 	intel_fb->obj = obj;
 
Signature · 6 lines
1.8.4.rc3

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 2 lines
Ville Syrjälä
Intel OTC