Re: [net-intel-i40e] question about assignment overwrite

From: Gustavo A. R. Silva
Date: Thu May 18 2017 - 13:44:17 EST


Hi Jeff,

Quoting Jeff Kirsher <jeffrey.t.kirsher@xxxxxxxxx>:

On Wed, 2017-05-17 at 15:48 -0500, Gustavo A. R. Silva wrote:
While looking into Coverity ID 1408956 I ran into the following
pieceÂÂ
of code at drivers/net/ethernet/intel/i40e/i40e_main.c:8807:

8807ÂÂÂÂÂÂÂ if (pf->hw.mac.type == I40E_MAC_X722) {
8808ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ pf->flags |= I40E_FLAG_RSS_AQ_CAPABLE
8809ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ | I40E_FLAG_128_QP_RSS_CAPABLE
8810ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ | I40E_FLAG_HW_ATR_EVICT_CAPABLE
8811ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ | I40E_FLAG_OUTER_UDP_CSUM_CAPABLE
8812ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ | I40E_FLAG_WB_ON_ITR_CAPABLE
8813ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ |
I40E_FLAG_MULTIPLE_TCP_UDP_RSS_PCTYPE
8814ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ | I40E_FLAG_NO_PCI_LINK_CHECK
8815ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ | I40E_FLAG_USE_SET_LLDP_MIB
8816ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ | I40E_FLAG_GENEVE_OFFLOAD_CAPABLE
8817ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ | I40E_FLAG_PTP_L4_CAPABLE
8818ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ | I40E_FLAG_WOL_MC_MAGIC_PKT_WAKE;
8819ÂÂÂÂÂÂÂ } else if ((pf->hw.aq.api_maj_ver > 1) ||
8820ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ ((pf->hw.aq.api_maj_ver == 1) &&
8821ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ (pf->hw.aq.api_min_ver > 4))) {
8822ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ /* Supported in FW API version higher than 1.4 */
8823ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ pf->flags |= I40E_FLAG_GENEVE_OFFLOAD_CAPABLE;
8824ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ pf->flags = I40E_FLAG_HW_ATR_EVICT_CAPABLE;
8825ÂÂÂÂÂÂÂ } else {
8826ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ pf->flags = I40E_FLAG_HW_ATR_EVICT_CAPABLE;
8827ÂÂÂÂÂÂÂ }

The issue here is that the assignment at line 8823 is overwritten
byÂÂ
the code at line 8824.

I'm suspicious that line 8824 should be remove and a patch like theÂÂ
following can be applied:

index d5c9c9e..48ffa73 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -8821,7 +8821,6 @@ static int i40e_sw_init(struct i40e_pf *pf)
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ (pf->hw.aq.api_min_ver > 4))) {
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ /* Supported in FW API version higher than 1.4 */
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ pf->flags |= I40E_FLAG_GENEVE_OFFLOAD_CAPABLE;
-ÂÂÂÂÂÂÂÂÂÂÂÂÂÂ pf->flags = I40E_FLAG_HW_ATR_EVICT_CAPABLE;
ÂÂÂÂÂÂÂÂ } else {
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ pf->flags = I40E_FLAG_HW_ATR_EVICT_CAPABLE;
ÂÂÂÂÂÂÂÂ }

What do you think?

This issue is already fixed in my dev-queue branch on my next-queue
tree.

Great, it's good to know.

Thanks!
--
Gustavo A. R. Silva