Skip to content

Commit

Permalink
ethdev: validate input in register info
Browse files Browse the repository at this point in the history
[ upstream commit 94af45f ]

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

Fixes: 7a3f27c ("ethdev: add access to specific device info")
Fixes: 936eda2 ("net/hns3: support dump register")

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>
  • Loading branch information
Chengchang Tang authored and steevenlee committed May 8, 2021
1 parent 2e6638d commit 963fcac
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
5 changes: 0 additions & 5 deletions drivers/net/hns3/hns3_regs.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,6 @@ hns3_get_regs(struct rte_eth_dev *eth_dev, struct rte_dev_reg_info *regs)
uint32_t *data;
int ret;

if (regs == NULL) {
hns3_err(hw, "the input parameter regs is NULL!");
return -EINVAL;
}

ret = hns3_get_regs_length(hw, &length);
if (ret)
return ret;
Expand Down
2 changes: 2 additions & 0 deletions lib/librte_ethdev/rte_ethdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -5258,6 +5258,8 @@ rte_eth_dev_get_reg_info(uint16_t port_id, struct rte_dev_reg_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_reg, -ENOTSUP);
Expand Down
1 change: 1 addition & 0 deletions lib/librte_ethdev/rte_ethdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -4395,6 +4395,7 @@ int rte_eth_dev_get_eeprom(uint16_t port_id, struct rte_dev_eeprom_info *info);
* @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.
Expand Down

0 comments on commit 963fcac

Please sign in to comment.