> -----Original Message-----
> From: Zhichao Zeng <zhichaox.z...@intel.com>
> Sent: Tuesday, September 6, 2022 10:29 AM
> To: dev@dpdk.org
> Cc: Yang, Qiming <qiming.y...@intel.com>; Zhou, YidingX
> <yidingx.z...@intel.com>; Zeng, ZhichaoX <zhichaox.z...@intel.com>;
> Zhang, Qi Z <qi.z.zh...@intel.com>
> Subject: [PATCH] net/ice: avoid out-of-bound access
> 
> Add judgment on 'ethdev_port_id' to avoid out-of-bound accessing the
> 'rte_eth_devices'.
> 
> Fixes: 6f8fba7e437e ("net/ice: support represented port flow action")
> 
> Signed-off-by: Zhichao Zeng <zhichaox.z...@intel.com>
> ---
>  drivers/net/ice/ice_switch_filter.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/net/ice/ice_switch_filter.c
> b/drivers/net/ice/ice_switch_filter.c
> index 240fa10750..59fb31aa9d 100644
> --- a/drivers/net/ice/ice_switch_filter.c
> +++ b/drivers/net/ice/ice_switch_filter.c
> @@ -1631,6 +1631,10 @@ ice_switch_parse_dcf_action(struct
> ice_dcf_adapter *ad,
>               case RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT:
>                       rule_info->sw_act.fltr_act = ICE_FWD_TO_VSI;
>                       act_ethdev = action->conf;
> +
> +                     if (!rte_eth_dev_is_valid_port(act_ethdev->port_id))
> +                             goto invalid;
> +
>                       repr_dev = &rte_eth_devices[act_ethdev->port_id];
> 
>                       if (!repr_dev->data)
> --
> 2.25.1

Tested and passed.

Tested-by: Ke Xu <ke1...@intel.com>

Reply via email to