]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
i40e: Add bounds check for ch[] array
authorPiotr Kwapulinski <piotr.kwapulinski@intel.com>
Wed, 24 Apr 2019 12:20:49 +0000 (05:20 -0700)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Fri, 14 Jun 2019 19:59:16 +0000 (12:59 -0700)
Add bounds check for ch[] array.
Use ARRAY_SIZE() to ensure that idx is within the range.

Signed-off-by: Piotr Kwapulinski <piotr.kwapulinski@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c

index 2390bfff7581161dee628586cf4ed25bf15c45e9..c4c71cf7c4d7f79c9e1bc12656f6e2f228c1046f 100644 (file)
@@ -2135,8 +2135,13 @@ static int i40e_vc_config_queues_msg(struct i40e_vf *vf, u8 *msg)
                        }
                }
 
-               if (vf->adq_enabled)
+               if (vf->adq_enabled) {
+                       if (idx >= ARRAY_SIZE(vf->ch)) {
+                               aq_ret = I40E_ERR_NO_AVAILABLE_VSI;
+                               goto error_param;
+                       }
                        vsi_id = vf->ch[idx].vsi_id;
+               }
 
                if (i40e_config_vsi_rx_queue(vf, vsi_id, vsi_queue_id,
                                             &qpi->rxq) ||
@@ -2152,6 +2157,10 @@ static int i40e_vc_config_queues_msg(struct i40e_vf *vf, u8 *msg)
                 * to its appropriate VSIs based on TC mapping
                 **/
                if (vf->adq_enabled) {
+                       if (idx >= ARRAY_SIZE(vf->ch)) {
+                               aq_ret = I40E_ERR_NO_AVAILABLE_VSI;
+                               goto error_param;
+                       }
                        if (j == (vf->ch[idx].num_qps - 1)) {
                                idx++;
                                j = 0; /* resetting the queue count */