net/i40e: fix boundary check in RSS config
authorChenxu Di <chenxux.di@intel.com>
Thu, 14 May 2020 07:07:20 +0000 (07:07 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 18 May 2020 18:35:57 +0000 (20:35 +0200)
This patch fixes (out-of-bounds read) coverity issue.

Coverity issue: 357699, 357694
Fixes: feaae285b342 ("net/i40e: support hash configuration in RSS flow")

Signed-off-by: Chenxu Di <chenxux.di@intel.com>
Reviewed-by: Jeff Guo <jia.guo@intel.com>
drivers/net/i40e/i40e_ethdev.c

index 749d85f..91dcd0e 100644 (file)
@@ -13179,6 +13179,9 @@ i40e_rss_config_hash_function(struct i40e_pf *pf,
                                break;
                }
 
+               if (i == UINT64_BIT)
+                       return -EINVAL;
+
                for (j = I40E_FILTER_PCTYPE_INVALID + 1;
                     j < I40E_FILTER_PCTYPE_MAX; j++) {
                        if (pf->adapter->pctypes_tbl[i] & (1ULL << j))
@@ -13311,6 +13314,9 @@ i40e_rss_clear_hash_function(struct i40e_pf *pf,
                                break;
                }
 
+               if (i == UINT64_BIT)
+                       return -EINVAL;
+
                for (j = I40E_FILTER_PCTYPE_INVALID + 1;
                     j < I40E_FILTER_PCTYPE_MAX; j++) {
                        if (pf->adapter->pctypes_tbl[i] & (1ULL << j))