i40e_pf_config_vf_rxq_number() discarded the rte_kvargs_process() return
value and unconditionally returned success, and its own return value was
then discarded by i40e_pf_parameter_init(). A malformed or out of range
queue-num-per-vf value was therefore silently ignored, leaving the
default in place with no indication to the user.

Every other rte_kvargs_process() call site in this driver already checks
its return value. Do the same here, so that a bad value fails probe
rather than being masked.

rte_kvargs_process() stops at the first failing pair, which preserves
the "first invalid or last valid one is used" behaviour already
documented in the warning above the call.

Signed-off-by: Stephen Hemminger <[email protected]>
---
 drivers/net/intel/i40e/i40e_ethdev.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/net/intel/i40e/i40e_ethdev.c 
b/drivers/net/intel/i40e/i40e_ethdev.c
index 3b17281952..a218e9f05e 100644
--- a/drivers/net/intel/i40e/i40e_ethdev.c
+++ b/drivers/net/intel/i40e/i40e_ethdev.c
@@ -4834,6 +4834,7 @@ static int i40e_pf_config_vf_rxq_number(struct 
rte_eth_dev *dev)
        struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
        struct rte_kvargs *kvlist;
        int kvargs_count;
+       int ret;
 
        /* set default queue number per VF as 4 */
        pf->vf_nb_qp_max = RTE_LIBRTE_I40E_QUEUE_NUM_PER_VF;
@@ -4856,12 +4857,12 @@ static int i40e_pf_config_vf_rxq_number(struct 
rte_eth_dev *dev)
                            "the first invalid or last valid one is used !",
                            ETH_I40E_QUEUE_NUM_PER_VF_ARG);
 
-       rte_kvargs_process(kvlist, ETH_I40E_QUEUE_NUM_PER_VF_ARG,
-                          i40e_pf_parse_vf_queue_number_handler, pf);
+       ret = rte_kvargs_process(kvlist, ETH_I40E_QUEUE_NUM_PER_VF_ARG,
+                                i40e_pf_parse_vf_queue_number_handler, pf);
 
        rte_kvargs_free(kvlist);
 
-       return 0;
+       return ret;
 }
 
 static int
@@ -4871,13 +4872,16 @@ i40e_pf_parameter_init(struct rte_eth_dev *dev)
        struct i40e_hw *hw = I40E_PF_TO_HW(pf);
        struct rte_pci_device *pci_dev = RTE_CLASS_TO_BUS_DEVICE(dev, *pci_dev);
        uint16_t qp_count = 0, vsi_count = 0;
+       int ret;
 
        if (pci_dev->max_vfs && !hw->func_caps.sr_iov_1_1) {
                PMD_INIT_LOG(ERR, "HW configuration doesn't support SRIOV");
                return -EINVAL;
        }
 
-       i40e_pf_config_vf_rxq_number(dev);
+       ret = i40e_pf_config_vf_rxq_number(dev);
+       if (ret != 0)
+               return ret;
 
        /* Add the parameter init for LFC */
        pf->fc_conf.pause_time = I40E_DEFAULT_PAUSE_TIME;
-- 
2.53.0

Reply via email to