drm/radeon/kms: add bounds checking to avivo pll algo
authorAlex Deucher <alexdeucher@gmail.com>
Mon, 14 Feb 2011 16:43:10 +0000 (11:43 -0500)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 24 Feb 2011 22:54:24 +0000 (14:54 -0800)
commit a4b40d5d97f5c9ad0b7f4bf2818291ca184bb433 upstream.

Prevent divider overflow.
Fixes:
https://bugzilla.kernel.org/show_bug.cgi?id=28932

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/gpu/drm/radeon/radeon_display.c

index a26a70d..c7d1fca 100644 (file)
@@ -461,6 +461,11 @@ static void avivo_get_fb_div(struct radeon_pll *pll,
        tmp *= target_clock;
        *fb_div = tmp / pll->reference_freq;
        *frac_fb_div = tmp % pll->reference_freq;
+
+        if (*fb_div > pll->max_feedback_div)
+               *fb_div = pll->max_feedback_div;
+        else if (*fb_div < pll->min_feedback_div)
+                *fb_div = pll->min_feedback_div;
 }
 
 static u32 avivo_get_post_div(struct radeon_pll *pll,
@@ -494,6 +499,11 @@ static u32 avivo_get_post_div(struct radeon_pll *pll,
                        post_div--;
        }
 
+       if (post_div > pll->max_post_div)
+               post_div = pll->max_post_div;
+       else if (post_div < pll->min_post_div)
+               post_div = pll->min_post_div;
+
        return post_div;
 }