From: Long Wu <long...@corigine.com>

The app will be destroyed if add a port flow action which its
destination port id is invalid.

Add a check to avoid the problem.

Cc: chaoyong...@corigine.com
Cc: sta...@dpdk.org

Signed-off-by: Long Wu <long...@corigine.com>
---
 drivers/net/nfp/flower/nfp_flower_flow.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c 
b/drivers/net/nfp/flower/nfp_flower_flow.c
index d127171fdb..24e7047407 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -931,7 +931,7 @@ nfp_flow_item_check_port(struct nfp_item_calculate_param 
*param)
        const struct rte_flow_item_port_id *port_id;
 
        port_id = param->item->spec;
-       if (port_id == NULL || port_id->id >= RTE_MAX_ETHPORTS)
+       if (port_id == NULL || rte_eth_dev_is_valid_port(port_id->id) == 0)
                return -ERANGE;
 
        return 0;
@@ -1256,7 +1256,7 @@ nfp_flow_action_check_port(struct 
nfp_action_calculate_param *param)
                port_id = action_port_id->id;
        }
 
-       if (port_id >= RTE_MAX_ETHPORTS)
+       if (rte_eth_dev_is_valid_port(port_id) == 0)
                return -ERANGE;
 
        return 0;
-- 
2.39.1

Reply via email to