drm/i915: fix a sprite watermark computation to avoid divide by zero if xpos<0
authorHai Lan <hai.lan@intel.com>
Wed, 15 Feb 2012 11:07:02 +0000 (19:07 +0800)
committerJesse Barnes <jbarnes@virtuousgeek.org>
Thu, 23 Feb 2012 16:56:40 +0000 (08:56 -0800)
When setting overlay position with x<0, it will divide 0 and make drm
driver crash.

Signed-off-by: Hai Lan <hai.lan@intel.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
drivers/gpu/drm/i915/intel_display.c

index f3afec2854d8094fedfe093d02e6156b0fa4810a..e654f32de197756c538ce6685745bc235a7bc28b 100644 (file)
@@ -4680,8 +4680,17 @@ sandybridge_compute_sprite_srwm(struct drm_device *dev, int plane,
 
        crtc = intel_get_crtc_for_plane(dev, plane);
        clock = crtc->mode.clock;
+       if (!clock) {
+               *sprite_wm = 0;
+               return false;
+       }
 
        line_time_us = (sprite_width * 1000) / clock;
+       if (!line_time_us) {
+               *sprite_wm = 0;
+               return false;
+       }
+
        line_count = (latency_ns / line_time_us + 1000) / 1000;
        line_size = sprite_width * pixel_size;