On 4/28/2023 11:27 AM, Denis Pryazhennikov wrote:
> The behaviour is undefined in the rte_eth_fec_set() function
> when the fec_capa parameter is equal to zero.
> Add a check to handle this case.
> 
> Signed-off-by: Denis Pryazhennikov <denis.pryazhenni...@arknetworks.am>
> Acked-by: Ivan Malov <ivan.ma...@arknetworks.am>
> Acked-by: Viacheslav Galaktionov <viacheslav.galaktio...@arknetworks.am>
> ---
>  lib/ethdev/rte_ethdev.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
> index 4d0325568322..d02ee161cf6d 100644
> --- a/lib/ethdev/rte_ethdev.c
> +++ b/lib/ethdev/rte_ethdev.c
> @@ -4751,6 +4751,11 @@ rte_eth_fec_set(uint16_t port_id, uint32_t fec_capa)
>       RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
>       dev = &rte_eth_devices[port_id];
>  
> +     if (fec_capa == 0) {
> +             RTE_ETHDEV_LOG(ERR, "At least one FEC mode should be 
> specified\n");
> +             return -EINVAL;
> +     }
> +
>       if (*dev->dev_ops->fec_set == NULL)
>               return -ENOTSUP;
>       ret = eth_err(port_id, (*dev->dev_ops->fec_set)(dev, fec_capa));

Acked-by: Ferruh Yigit <ferruh.yi...@amd.com>

Reply via email to