DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Min Hu (Connor)" <humin29@huawei.com>
To: <dev@dpdk.org>
Cc: <ferruh.yigit@intel.com>
Subject: [dpdk-dev] [PATCH v2 3/3] ethdev: fix miss input validation when access EEPROM info
Date: Fri, 2 Apr 2021 10:58:50 +0800	[thread overview]
Message-ID: <1617332330-25936-4-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 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>
---
 lib/librte_ethdev/rte_ethdev.c | 4 ++++
 lib/librte_ethdev/rte_ethdev.h | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index 3fe200d..6b5cfd6 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -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);
diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h
index 554d11f..1a0382e 100644
--- a/lib/librte_ethdev/rte_ethdev.h
+++ b/lib/librte_ethdev/rte_ethdev.h
@@ -4429,6 +4429,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.
@@ -4447,6 +4448,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.
  */
-- 
2.7.4


  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   ` [dpdk-dev] [PATCH v2 2/3] ethdev: fix miss input validation when access reg info Min Hu (Connor)
2021-04-02  2:58   ` Min Hu (Connor) [this message]
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-4-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).