]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/2.6.36.2/ath9k_hw-fix-divide-by-zero-cases-in-paprd.patch
fixes for 4.19
[thirdparty/kernel/stable-queue.git] / releases / 2.6.36.2 / ath9k_hw-fix-divide-by-zero-cases-in-paprd.patch
1 From 2d3fca180710c6832de22c44155ce6a3a4953c6b Mon Sep 17 00:00:00 2001
2 From: Senthil Balasubramanian <senthilkumar@atheros.com>
3 Date: Tue, 19 Oct 2010 20:01:41 +0530
4 Subject: ath9k_hw: Fix divide by zero cases in paprd.
5
6 From: Senthil Balasubramanian <senthilkumar@atheros.com>
7
8 commit 2d3fca180710c6832de22c44155ce6a3a4953c6b upstream.
9
10 We are not handling all divide by zero cases in paprd.
11 Add additional checks for divide by zero cases in papard.
12
13 This patch has fixes intended for kernel 2.6.36.
14
15 Signed-off-by: Senthil Balasubramanian <senthilkumar@atheros.com>
16 Signed-off-by: John W. Linville <linville@tuxdriver.com>
17 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
18
19 ---
20 drivers/net/wireless/ath/ath9k/ar9003_paprd.c | 14 +++++++++-----
21 1 file changed, 9 insertions(+), 5 deletions(-)
22
23 --- a/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
24 +++ b/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
25 @@ -347,6 +347,10 @@ static bool create_pa_curve(u32 *data_L,
26 (((Y[6] - Y[3]) * 1 << scale_factor) +
27 (x_est[6] - x_est[3])) / (x_est[6] - x_est[3]);
28
29 + /* prevent division by zero */
30 + if (G_fxp == 0)
31 + return false;
32 +
33 Y_intercept =
34 (G_fxp * (x_est[0] - x_est[3]) +
35 (1 << scale_factor)) / (1 << scale_factor) + Y[3];
36 @@ -356,14 +360,12 @@ static bool create_pa_curve(u32 *data_L,
37
38 for (i = 0; i <= 3; i++) {
39 y_est[i] = i * 32;
40 -
41 - /* prevent division by zero */
42 - if (G_fxp == 0)
43 - return false;
44 -
45 x_est[i] = ((y_est[i] * 1 << scale_factor) + G_fxp) / G_fxp;
46 }
47
48 + if (y_est[max_index] == 0)
49 + return false;
50 +
51 x_est_fxp1_nonlin =
52 x_est[max_index] - ((1 << scale_factor) * y_est[max_index] +
53 G_fxp) / G_fxp;
54 @@ -457,6 +459,8 @@ static bool create_pa_curve(u32 *data_L,
55
56 Q_scale_B = find_proper_scale(find_expn(abs(scale_B)), 10);
57 scale_B = scale_B / (1 << Q_scale_B);
58 + if (scale_B == 0)
59 + return false;
60 Q_beta = find_proper_scale(find_expn(abs(beta_raw)), 10);
61 Q_alpha = find_proper_scale(find_expn(abs(alpha_raw)), 10);
62 beta_raw = beta_raw / (1 << Q_beta);