diff options
author | Senthil Balasubramanian <senthilkumar@atheros.com> | 2010-10-19 10:31:41 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2010-10-25 14:43:14 -0400 |
commit | 2d3fca180710c6832de22c44155ce6a3a4953c6b (patch) | |
tree | 00f2b5f961776177638b27d449c83c89b34323d8 /drivers/net/wireless | |
parent | 0dfa6dbb7372e581d3beb38b11772152114796b8 (diff) |
ath9k_hw: Fix divide by zero cases in paprd.
We are not handling all divide by zero cases in paprd.
Add additional checks for divide by zero cases in papard.
This patch has fixes intended for kernel 2.6.36.
Cc: stable@kernel.org
Signed-off-by: Senthil Balasubramanian <senthilkumar@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r-- | drivers/net/wireless/ath/ath9k/ar9003_paprd.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_paprd.c b/drivers/net/wireless/ath/ath9k/ar9003_paprd.c index 7c38229ba670..716db414c258 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_paprd.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_paprd.c | |||
@@ -347,6 +347,10 @@ static bool create_pa_curve(u32 *data_L, u32 *data_U, u32 *pa_table, u16 *gain) | |||
347 | (((Y[6] - Y[3]) * 1 << scale_factor) + | 347 | (((Y[6] - Y[3]) * 1 << scale_factor) + |
348 | (x_est[6] - x_est[3])) / (x_est[6] - x_est[3]); | 348 | (x_est[6] - x_est[3])) / (x_est[6] - x_est[3]); |
349 | 349 | ||
350 | /* prevent division by zero */ | ||
351 | if (G_fxp == 0) | ||
352 | return false; | ||
353 | |||
350 | Y_intercept = | 354 | Y_intercept = |
351 | (G_fxp * (x_est[0] - x_est[3]) + | 355 | (G_fxp * (x_est[0] - x_est[3]) + |
352 | (1 << scale_factor)) / (1 << scale_factor) + Y[3]; | 356 | (1 << scale_factor)) / (1 << scale_factor) + Y[3]; |
@@ -356,14 +360,12 @@ static bool create_pa_curve(u32 *data_L, u32 *data_U, u32 *pa_table, u16 *gain) | |||
356 | 360 | ||
357 | for (i = 0; i <= 3; i++) { | 361 | for (i = 0; i <= 3; i++) { |
358 | y_est[i] = i * 32; | 362 | y_est[i] = i * 32; |
359 | |||
360 | /* prevent division by zero */ | ||
361 | if (G_fxp == 0) | ||
362 | return false; | ||
363 | |||
364 | x_est[i] = ((y_est[i] * 1 << scale_factor) + G_fxp) / G_fxp; | 363 | x_est[i] = ((y_est[i] * 1 << scale_factor) + G_fxp) / G_fxp; |
365 | } | 364 | } |
366 | 365 | ||
366 | if (y_est[max_index] == 0) | ||
367 | return false; | ||
368 | |||
367 | x_est_fxp1_nonlin = | 369 | x_est_fxp1_nonlin = |
368 | x_est[max_index] - ((1 << scale_factor) * y_est[max_index] + | 370 | x_est[max_index] - ((1 << scale_factor) * y_est[max_index] + |
369 | G_fxp) / G_fxp; | 371 | G_fxp) / G_fxp; |
@@ -457,6 +459,8 @@ static bool create_pa_curve(u32 *data_L, u32 *data_U, u32 *pa_table, u16 *gain) | |||
457 | 459 | ||
458 | Q_scale_B = find_proper_scale(find_expn(abs(scale_B)), 10); | 460 | Q_scale_B = find_proper_scale(find_expn(abs(scale_B)), 10); |
459 | scale_B = scale_B / (1 << Q_scale_B); | 461 | scale_B = scale_B / (1 << Q_scale_B); |
462 | if (scale_B == 0) | ||
463 | return false; | ||
460 | Q_beta = find_proper_scale(find_expn(abs(beta_raw)), 10); | 464 | Q_beta = find_proper_scale(find_expn(abs(beta_raw)), 10); |
461 | Q_alpha = find_proper_scale(find_expn(abs(alpha_raw)), 10); | 465 | Q_alpha = find_proper_scale(find_expn(abs(alpha_raw)), 10); |
462 | beta_raw = beta_raw / (1 << Q_beta); | 466 | beta_raw = beta_raw / (1 << Q_beta); |