[09/70] drm/radeon/kms: add bounds checking to avivo pll algo

From: Greg KH
Date: Tue Feb 22 2011 - 17:36:27 EST


2.6.37-stable review patch. If anyone has any objections, please let us know.

------------------

From: Alex Deucher <alexdeucher@xxxxxxxxx>

commit a4b40d5d97f5c9ad0b7f4bf2818291ca184bb433 upstream.

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

Signed-off-by: Alex Deucher <alexdeucher@xxxxxxxxx>
Signed-off-by: Dave Airlie <airlied@xxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxx>

---
drivers/gpu/drm/radeon/radeon_display.c | 10 ++++++++++
1 file changed, 10 insertions(+)

--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -461,6 +461,11 @@ static void avivo_get_fb_div(struct rade
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 rad
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;
}



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/