ethdev: validate input in EEPROM info

This patch adds validity check of input pointer in EEPROM dump API.

Fixes: 7a3f27cbf59b ("ethdev: add access to specific device info")
Cc: stable@dpdk.org

Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
This commit is contained in:
Chengchang Tang 2021-04-02 10:58:50 +08:00 committed by Ferruh Yigit
parent 94af45f400
commit 18239da4ac
2 changed files with 6 additions and 0 deletions

View File

@ -5312,6 +5312,8 @@ rte_eth_dev_get_eeprom(uint16_t port_id, struct rte_dev_eeprom_info *info)
struct rte_eth_dev *dev;
RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
if (info == NULL)
return -EINVAL;
dev = &rte_eth_devices[port_id];
RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->get_eeprom, -ENOTSUP);
@ -5324,6 +5326,8 @@ rte_eth_dev_set_eeprom(uint16_t port_id, struct rte_dev_eeprom_info *info)
struct rte_eth_dev *dev;
RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
if (info == NULL)
return -EINVAL;
dev = &rte_eth_devices[port_id];
RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_eeprom, -ENOTSUP);

View File

@ -4435,6 +4435,7 @@ int rte_eth_dev_get_eeprom_length(uint16_t port_id);
* @return
* - (0) if successful.
* - (-ENOTSUP) if hardware doesn't support.
* - (-EINVAL) if bad parameter.
* - (-ENODEV) if *port_id* invalid.
* - (-EIO) if device is removed.
* - others depends on the specific operations implementation.
@ -4453,6 +4454,7 @@ int rte_eth_dev_get_eeprom(uint16_t port_id, struct rte_dev_eeprom_info *info);
* - (0) if successful.
* - (-ENOTSUP) if hardware doesn't support.
* - (-ENODEV) if *port_id* invalid.
* - (-EINVAL) if bad parameter.
* - (-EIO) if device is removed.
* - others depends on the specific operations implementation.
*/