From patchwork Mon Aug 24 11:01:30 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: 75879 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 E3C64A04AC; Mon, 24 Aug 2020 13:02:19 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0EE9D1C0B1; Mon, 24 Aug 2020 13:02:00 +0200 (CEST) Received: from mail.chinasoftinc.com (unknown [114.113.233.8]) by dpdk.org (Postfix) with ESMTP id 20CB258C4 for ; Mon, 24 Aug 2020 13:01:56 +0200 (CEST) Received: from localhost.localdomain (120.133.139.157) by INCCAS002.ito.icss (10.168.0.60) with Microsoft SMTP Server id 14.3.487.0; Mon, 24 Aug 2020 19:01:50 +0800 From: "Wei Hu (Xavier)" To: Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko CC: , Date: Mon, 24 Aug 2020 19:01:30 +0800 Message-ID: <20200824110130.16647-4-huwei013@chinasoftinc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200824110130.16647-1-huwei013@chinasoftinc.com> References: <20200818025132.27912-1-huwei013@chinasoftinc.com> <20200824110130.16647-1-huwei013@chinasoftinc.com> MIME-Version: 1.0 X-Originating-IP: [120.133.139.157] Subject: [dpdk-dev] [PATCH v4 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) Reviewed-by: Ferruh Yigit --- 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",