[RFC,v2,2/3] ethdev: check that at least one FEC mode is specified
Checks
Commit Message
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.pryazhennikov@arknetworks.am>
Acked-by: Ivan Malov <ivan.malov@arknetworks.am>
Acked-by: Viacheslav Galaktionov <viacheslav.galaktionov@arknetworks.am>
---
lib/ethdev/rte_ethdev.c | 5 +++++
1 file changed, 5 insertions(+)
@@ -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));