From: "Min Hu (Connor)" <humin29@huawei.com>
To: <dev@dpdk.org>
Cc: <ferruh.yigit@intel.com>
Subject: [dpdk-dev] [PATCH v2 2/3] ethdev: fix miss input validation when access reg info
Date: Fri, 2 Apr 2021 10:58:49 +0800 [thread overview]
Message-ID: <1617332330-25936-3-git-send-email-humin29@huawei.com> (raw)
In-Reply-To: <1617332330-25936-1-git-send-email-humin29@huawei.com>
From: Chengchang Tang <tangchengchang@huawei.com>
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>
---
drivers/net/hns3/hns3_regs.c | 5 -----
lib/librte_ethdev/rte_ethdev.c | 2 ++
lib/librte_ethdev/rte_ethdev.h | 1 +
3 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/net/hns3/hns3_regs.c b/drivers/net/hns3/hns3_regs.c
index 4022bb9..f23e5c2 100644
--- a/drivers/net/hns3/hns3_regs.c
+++ b/drivers/net/hns3/hns3_regs.c
@@ -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;
diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index bb195ab..3fe200d 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -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);
diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h
index 7cdb3fa..554d11f 100644
--- a/lib/librte_ethdev/rte_ethdev.h
+++ b/lib/librte_ethdev/rte_ethdev.h
@@ -4397,6 +4397,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.
--
2.7.4
next prev parent reply other threads:[~2021-04-02 2:58 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-27 7:38 [dpdk-dev] [PATCH 0/3] fix miss input validation Min Hu (Connor)
2021-03-27 7:38 ` [dpdk-dev] [PATCH 1/3] ethdev: fix miss input validation in module EEPROM dump API Min Hu (Connor)
2021-04-01 15:15 ` Ferruh Yigit
2021-03-27 7:38 ` [dpdk-dev] [PATCH 2/3] ethdev: fix miss input validation when access reg info Min Hu (Connor)
2021-04-01 15:15 ` Ferruh Yigit
2021-03-27 7:38 ` [dpdk-dev] [PATCH 3/3] ethdev: fix miss input validation when access EEPROM info Min Hu (Connor)
2021-04-01 15:27 ` Ferruh Yigit
2021-04-01 15:37 ` [dpdk-dev] [PATCH 0/3] fix miss input validation Ferruh Yigit
2021-04-02 2:59 ` Min Hu (Connor)
2021-04-02 2:58 ` [dpdk-dev] [PATCH v2 " Min Hu (Connor)
2021-04-02 2:58 ` [dpdk-dev] [PATCH v2 1/3] ethdev: fix miss input validation in module EEPROM dump API Min Hu (Connor)
2021-04-02 2:58 ` Min Hu (Connor) [this message]
2021-04-02 2:58 ` [dpdk-dev] [PATCH v2 3/3] ethdev: fix miss input validation when access EEPROM info Min Hu (Connor)
2021-04-06 7:53 ` [dpdk-dev] [PATCH v2 0/3] fix miss input validation Ferruh Yigit
2021-04-07 22:28 ` Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1617332330-25936-3-git-send-email-humin29@huawei.com \
--to=humin29@huawei.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).