ath9k: Fix possible overflow condition
authorSujith Manoharan <c_manoha@qca.qualcomm.com>
Tue, 14 Jan 2014 08:11:17 +0000 (13:41 +0530)
committerJohn W. Linville <linville@tuxdriver.com>
Thu, 16 Jan 2014 19:55:42 +0000 (14:55 -0500)
Prevent a possible overflow condition which results in occasional
bad IQ coefficients and EVM numbers.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/ath/ath9k/ar9003_calib.c

index 4eb35aa64f350cd094aef9bd6392760531071c8f..a352128c40ad370600df154ad868f48c5fe7854a 100644 (file)
@@ -565,7 +565,7 @@ static bool ar9003_hw_solve_iq_cal(struct ath_hw *ah,
        const s32 result_shift = 1 << 15;
        struct ath_common *common = ath9k_hw_common(ah);
 
-       f2 = (f1 * f1 + f3 * f3) / result_shift;
+       f2 = ((f1 >> 3) * (f1 >> 3) + (f3 >> 3) * (f3 >> 3)) >> 9;
 
        if (!f2) {
                ath_dbg(common, CALIBRATE, "Divide by 0\n");