From patchwork Thu Aug 20 09:03:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wei Hu (Xavier)" X-Patchwork-Id: 75736 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id C4026A04AF; Thu, 20 Aug 2020 11:04:49 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 491C51C0C1; Thu, 20 Aug 2020 11:04:29 +0200 (CEST) Received: from mail.chinasoftinc.com (unknown [114.113.233.8]) by dpdk.org (Postfix) with ESMTP id E9F381C031 for ; Thu, 20 Aug 2020 11:04:27 +0200 (CEST) Received: from localhost.localdomain (65.49.108.226) by INCCAS002.ito.icss (10.168.0.60) with Microsoft SMTP Server id 14.3.487.0; Thu, 20 Aug 2020 17:04:24 +0800 From: "Wei Hu (Xavier)" To: , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko CC: Date: Thu, 20 Aug 2020 17:03:51 +0800 Message-ID: <20200820090351.3780-4-huwei013@chinasoftinc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200820090351.3780-1-huwei013@chinasoftinc.com> References: <20200818025132.27912-1-huwei013@chinasoftinc.com> <20200820090351.3780-1-huwei013@chinasoftinc.com> MIME-Version: 1.0 X-Originating-IP: [65.49.108.226] Subject: [dpdk-dev] [PATCH v3 3/3] ethdev: check if queue setupped when getting queue info X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: "Wei Hu (Xavier)" 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) --- 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",