Commit 8e650987 authored by Antonino A. Daplas's avatar Antonino A. Daplas Committed by Linus Torvalds

[PATCH] aty128fb: Fix array overrun

Fix static array overrun

Coverity Bug 556
Signed-off-by: default avatarAntonino Daplas <adaplas@pol.net>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 54243cef
...@@ -1326,7 +1326,7 @@ static int aty128_var_to_pll(u32 period_in_ps, struct aty128_pll *pll, ...@@ -1326,7 +1326,7 @@ static int aty128_var_to_pll(u32 period_in_ps, struct aty128_pll *pll,
unsigned char post_dividers[] = {1,2,4,8,3,6,12}; unsigned char post_dividers[] = {1,2,4,8,3,6,12};
u32 output_freq; u32 output_freq;
u32 vclk; /* in .01 MHz */ u32 vclk; /* in .01 MHz */
int i; int i = 0;
u32 n, d; u32 n, d;
vclk = 100000000 / period_in_ps; /* convert units to 10 kHz */ vclk = 100000000 / period_in_ps; /* convert units to 10 kHz */
...@@ -1340,15 +1340,16 @@ static int aty128_var_to_pll(u32 period_in_ps, struct aty128_pll *pll, ...@@ -1340,15 +1340,16 @@ static int aty128_var_to_pll(u32 period_in_ps, struct aty128_pll *pll,
/* now, find an acceptable divider */ /* now, find an acceptable divider */
for (i = 0; i < sizeof(post_dividers); i++) { for (i = 0; i < sizeof(post_dividers); i++) {
output_freq = post_dividers[i] * vclk; output_freq = post_dividers[i] * vclk;
if (output_freq >= c.ppll_min && output_freq <= c.ppll_max) if (output_freq >= c.ppll_min && output_freq <= c.ppll_max) {
pll->post_divider = post_dividers[i];
break; break;
}
} }
/* calculate feedback divider */ /* calculate feedback divider */
n = c.ref_divider * output_freq; n = c.ref_divider * output_freq;
d = c.ref_clk; d = c.ref_clk;
pll->post_divider = post_dividers[i];
pll->feedback_divider = round_div(n, d); pll->feedback_divider = round_div(n, d);
pll->vclk = vclk; pll->vclk = vclk;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment