Skip to content

Commit

Permalink
ethdev: check that at least one FEC mode is specified
Browse files Browse the repository at this point in the history
[ upstream commit 9fdcf2be070dcd5ea3d845ce798c298c5dfbaa4a ]

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.

Fixes: b7ccfb0 ("ethdev: introduce FEC API")

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>
Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
  • Loading branch information
okt-denispr authored and kevintraynor committed Jul 12, 2023
1 parent d53afe6 commit b6557a7
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/ethdev/rte_ethdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -4351,6 +4351,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;
}

RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fec_set, -ENOTSUP);
return eth_err(port_id, (*dev->dev_ops->fec_set)(dev, fec_capa));
}
Expand Down

0 comments on commit b6557a7

Please sign in to comment.