@@ -1903,13 +1903,21 @@ static int ice_vc_cfg_q_bw(struct ice_vf *vf, u8 *msg)
19031903 */
19041904static int ice_vc_cfg_q_quanta (struct ice_vf * vf , u8 * msg )
19051905{
1906+ u16 quanta_prof_id , quanta_size , start_qid , num_queues , end_qid , i ;
19061907 enum virtchnl_status_code v_ret = VIRTCHNL_STATUS_SUCCESS ;
1907- u16 quanta_prof_id , quanta_size , start_qid , end_qid , i ;
19081908 struct virtchnl_quanta_cfg * qquanta =
19091909 (struct virtchnl_quanta_cfg * )msg ;
19101910 struct ice_vsi * vsi ;
19111911 int ret ;
19121912
1913+ start_qid = qquanta -> queue_select .start_queue_id ;
1914+ num_queues = qquanta -> queue_select .num_queues ;
1915+
1916+ if (check_add_overflow (start_qid , num_queues , & end_qid )) {
1917+ v_ret = VIRTCHNL_STATUS_ERR_PARAM ;
1918+ goto err ;
1919+ }
1920+
19131921 if (!test_bit (ICE_VF_STATE_ACTIVE , vf -> vf_states )) {
19141922 v_ret = VIRTCHNL_STATUS_ERR_PARAM ;
19151923 goto err ;
@@ -1921,8 +1929,6 @@ static int ice_vc_cfg_q_quanta(struct ice_vf *vf, u8 *msg)
19211929 goto err ;
19221930 }
19231931
1924- end_qid = qquanta -> queue_select .start_queue_id +
1925- qquanta -> queue_select .num_queues ;
19261932 if (end_qid > ICE_MAX_RSS_QS_PER_VF ||
19271933 end_qid > min_t (u16 , vsi -> alloc_txq , vsi -> alloc_rxq )) {
19281934 dev_err (ice_pf_to_dev (vf -> pf ), "VF-%d trying to configure more than allocated number of queues: %d\n" ,
@@ -1951,7 +1957,6 @@ static int ice_vc_cfg_q_quanta(struct ice_vf *vf, u8 *msg)
19511957 goto err ;
19521958 }
19531959
1954- start_qid = qquanta -> queue_select .start_queue_id ;
19551960 for (i = start_qid ; i < end_qid ; i ++ )
19561961 vsi -> tx_rings [i ]-> quanta_prof_id = quanta_prof_id ;
19571962
0 commit comments