DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Wei Hu (Xavier)" <huwei013@chinasoftinc.com>
To: Thomas Monjalon <thomas@monjalon.net>,
	Ferruh Yigit <ferruh.yigit@intel.com>,
	Andrew Rybchenko <arybchenko@solarflare.com>
Cc: <dev@dpdk.org>, <xavier.huwei@huawei.com>
Subject: [dpdk-dev] [PATCH v4 3/3] ethdev: check if queue setupped when getting queue info
Date: Mon, 24 Aug 2020 19:01:30 +0800
Message-ID: <20200824110130.16647-4-huwei013@chinasoftinc.com> (raw)
In-Reply-To: <20200824110130.16647-1-huwei013@chinasoftinc.com>

From: "Wei Hu (Xavier)" <xavier.huwei@huawei.com>

This patch adds checking whether the related Tx or Rx queue has been
setuped in the rte_eth_rx_queue_info_get and rte_eth_tx_queue_info_get
API function to avoid illegal address access.

Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
---
 lib/librte_ethdev/rte_ethdev.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index 7858ad5f1..0503c7929 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -4670,6 +4670,14 @@ rte_eth_rx_queue_info_get(uint16_t port_id, uint16_t queue_id,
 		return -EINVAL;
 	}
 
+	if (dev->data->rx_queues[queue_id] == NULL) {
+		RTE_ETHDEV_LOG(ERR,
+			       "Rx queue %"PRIu16" of device with port_id=%"
+			       PRIu16" has not been setuped\n",
+			       queue_id, port_id);
+		return -EINVAL;
+	}
+
 	if (rte_eth_dev_is_rx_hairpin_queue(dev, queue_id)) {
 		RTE_ETHDEV_LOG(INFO,
 			"Can't get hairpin Rx queue %"PRIu16" info of device with port_id=%"PRIu16"\n",
@@ -4701,6 +4709,14 @@ rte_eth_tx_queue_info_get(uint16_t port_id, uint16_t queue_id,
 		return -EINVAL;
 	}
 
+	if (dev->data->tx_queues[queue_id] == NULL) {
+		RTE_ETHDEV_LOG(ERR,
+			       "Tx queue %"PRIu16" of device with port_id=%"
+			       PRIu16" has not been setuped\n",
+			       queue_id, port_id);
+		return -EINVAL;
+	}
+
 	if (rte_eth_dev_is_tx_hairpin_queue(dev, queue_id)) {
 		RTE_ETHDEV_LOG(INFO,
 			"Can't get hairpin Tx queue %"PRIu16" info of device with port_id=%"PRIu16"\n",
-- 
2.27.0


  parent reply	other threads:[~2020-08-24 11:02 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-18  2:51 [dpdk-dev] [PATCH] net/hns3: support getting Tx and Rx queue information Wei Hu (Xavier)
2020-08-18  3:07 ` [dpdk-dev] [PATCH V2] " Wei Hu (Xavier)
2020-08-19 16:19   ` Ferruh Yigit
2020-08-20  9:07     ` Wei Hu (Xavier)
2020-08-20  9:03 ` [dpdk-dev] [PATCH v3 0/3] minor updates for getting queue info Wei Hu (Xavier)
2020-08-20  9:03   ` [dpdk-dev] [PATCH v3 1/3] net/hns3: report Rx drop packets enable configuration Wei Hu (Xavier)
2020-08-20  9:03   ` [dpdk-dev] [PATCH v3 2/3] net/hns3: support getting Tx and Rx queue information Wei Hu (Xavier)
2020-08-20  9:03   ` [dpdk-dev] [PATCH v3 3/3] ethdev: check if queue setupped when getting queue info Wei Hu (Xavier)
2020-08-24 11:01 ` [dpdk-dev] [PATCH v4 0/3] minor updates for " Wei Hu (Xavier)
2020-08-24 11:01   ` [dpdk-dev] [PATCH v4 1/3] net/hns3: report Rx drop packets enable configuration Wei Hu (Xavier)
2020-08-24 11:01   ` [dpdk-dev] [PATCH v4 2/3] net/hns3: support getting Tx and Rx queue information Wei Hu (Xavier)
2020-08-24 11:01   ` Wei Hu (Xavier) [this message]
2020-08-25  8:43     ` [dpdk-dev] [PATCH v4 3/3] ethdev: check if queue setupped when getting queue info Ferruh Yigit
2020-08-25  8:44   ` [dpdk-dev] [PATCH v4 0/3] minor updates for " 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=20200824110130.16647-4-huwei013@chinasoftinc.com \
    --to=huwei013@chinasoftinc.com \
    --cc=arybchenko@solarflare.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=thomas@monjalon.net \
    --cc=xavier.huwei@huawei.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

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git