net/i40e/base: fix using checksum before check
authorRobin Zhang <robinx.zhang@intel.com>
Sat, 9 Oct 2021 01:39:51 +0000 (01:39 +0000)
committerQi Zhang <qi.z.zhang@intel.com>
Sat, 9 Oct 2021 05:37:05 +0000 (07:37 +0200)
The variable checksum from i40e_calc_nvm_checksum is used before return
value is checked. Fix this logic.

Fixes: 8db9e2a1b232 ("i40e: base driver")
Fixes: 3ed6c3246f43 ("i40e/base: handle AQ timeout when releasing NVM")
Cc: stable@dpdk.org
Signed-off-by: Christopher Pau <christopher.pau@intel.com>
Signed-off-by: Robin Zhang <robinx.zhang@intel.com>
Acked-by: Beilei Xing <beilei.xing@intel.com>
drivers/net/i40e/base/i40e_nvm.c

index 67e58cc..f385042 100644 (file)
@@ -755,10 +755,11 @@ enum i40e_status_code i40e_update_nvm_checksum(struct i40e_hw *hw)
        DEBUGFUNC("i40e_update_nvm_checksum");
 
        ret_code = i40e_calc_nvm_checksum(hw, &checksum);
-       le_sum = CPU_TO_LE16(checksum);
-       if (ret_code == I40E_SUCCESS)
+       if (ret_code == I40E_SUCCESS) {
+               le_sum = CPU_TO_LE16(checksum);
                ret_code = i40e_write_nvm_aq(hw, 0x00, I40E_SR_SW_CHECKSUM_WORD,
                                             1, &le_sum, true);
+       }
 
        return ret_code;
 }