ethdev: validate input in register info
authorChengchang Tang <tangchengchang@huawei.com>
Fri, 2 Apr 2021 02:58:49 +0000 (10:58 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Wed, 7 Apr 2021 22:26:39 +0000 (00:26 +0200)
This patch adds validity check of input pointer in regs dump API.

Fixes: 7a3f27cbf59b ("ethdev: add access to specific device info")
Fixes: 936eda25e8da ("net/hns3: support dump register")
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>
drivers/net/hns3/hns3_regs.c
lib/librte_ethdev/rte_ethdev.c
lib/librte_ethdev/rte_ethdev.h

index d53c132..5d15613 100644 (file)
@@ -484,11 +484,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;
index bb195ab..3fe200d 100644 (file)
@@ -5286,6 +5286,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);
index f5bbc10..1ad7cda 100644 (file)
@@ -4403,6 +4403,7 @@ int rte_eth_get_monitor_addr(uint16_t port_id, uint16_t queue_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.