reported by smatch
phy.c:854 rtw_phy_linear_2_db() error: buffer overflow 'db_invert_table[i]'
8 <= 8 (assuming for loop doesn't break)
However, it seems to be a false alarm because we prevent it originally via
       if (linear >= db_invert_table[11][7])
               return 96; /* maximum 96 dB */
Still, we adjust the code to be more readable and avoid smatch warning.
Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220727065003.28340-5-pkshih@realtek.com
        u8 j;
        u32 dB;
 
-       if (linear >= db_invert_table[11][7])
-               return 96; /* maximum 96 dB */
-
        for (i = 0; i < 12; i++) {
-               if (i <= 2 && (linear << FRAC_BITS) <= db_invert_table[i][7])
-                       break;
-               else if (i > 2 && linear <= db_invert_table[i][7])
-                       break;
+               for (j = 0; j < 8; j++) {
+                       if (i <= 2 && (linear << FRAC_BITS) <= db_invert_table[i][j])
+                               goto cnt;
+                       else if (i > 2 && linear <= db_invert_table[i][j])
+                               goto cnt;
+               }
        }
 
-       for (j = 0; j < 8; j++) {
-               if (i <= 2 && (linear << FRAC_BITS) <= db_invert_table[i][j])
-                       break;
-               else if (i > 2 && linear <= db_invert_table[i][j])
-                       break;
-       }
+       return 96; /* maximum 96 dB */
 
+cnt:
        if (j == 0 && i == 0)
                goto end;