From patchwork Thu Oct 1 18:14:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ferruh Yigit X-Patchwork-Id: 79491 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 12A2AA04BA; Thu, 1 Oct 2020 20:14:11 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8835F1D54A; Thu, 1 Oct 2020 20:14:09 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id C69611D44A for ; Thu, 1 Oct 2020 20:14:06 +0200 (CEST) IronPort-SDR: QNDUZ/6J3EFDV8BnQLKTzXKb3dDlgY/Pkb+cN6q9buFeGHXsr78uu1qXtdRJXITbrsUC0o8fuL RW9I7u1z38QQ== X-IronPort-AV: E=McAfee;i="6000,8403,9761"; a="163659771" X-IronPort-AV: E=Sophos;i="5.77,324,1596524400"; d="scan'208";a="163659771" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Oct 2020 11:14:05 -0700 IronPort-SDR: hfKrhduKs6Ri3ch1iP5yocmb4/pMPeN4Dm6cvK1xg5aSk+1N+34YjOIfXRd5e/go5lMshdvfaY qPCGxkdmf6Yw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,324,1596524400"; d="scan'208";a="514830140" Received: from silpixa00399752.ir.intel.com (HELO silpixa00399752.ger.corp.intel.com) ([10.237.222.180]) by fmsmga006.fm.intel.com with ESMTP; 01 Oct 2020 11:14:04 -0700 From: Ferruh Yigit To: Thomas Monjalon , Andrew Rybchenko , "Wei Hu (Xavier)" Cc: dev@dpdk.org, Ferruh Yigit Date: Thu, 1 Oct 2020 19:14:02 +0100 Message-Id: <20201001181402.28327-1-ferruh.yigit@intel.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH] ethdev: check if queues are allocated before getting 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" A crash is detected when '--txpkts=#' parameter provided to the testpmd, this is because queue information is requested before queues have been allocated. Adding check to queue info APIs ('rte_eth_rx_queue_info_get()' & 'rte_eth_tx_queue_info_get') to protect against similar cases. Fixes: ba2fb4f022fc ("ethdev: check if queue setup when getting queue info") Signed-off-by: Ferruh Yigit Reviewed-by: Ajit Khaparde --- lib/librte_ethdev/rte_ethdev.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 0f56541fbc..9805184633 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -4688,7 +4688,8 @@ rte_eth_rx_queue_info_get(uint16_t port_id, uint16_t queue_id, return -EINVAL; } - if (dev->data->rx_queues[queue_id] == NULL) { + if (dev->data->rx_queues == NULL || + dev->data->rx_queues[queue_id] == NULL) { RTE_ETHDEV_LOG(ERR, "Rx queue %"PRIu16" of device with port_id=%" PRIu16" has not been setup\n", @@ -4727,7 +4728,8 @@ rte_eth_tx_queue_info_get(uint16_t port_id, uint16_t queue_id, return -EINVAL; } - if (dev->data->tx_queues[queue_id] == NULL) { + if (dev->data->tx_queues == NULL || + dev->data->tx_queues[queue_id] == NULL) { RTE_ETHDEV_LOG(ERR, "Tx queue %"PRIu16" of device with port_id=%" PRIu16" has not been setup\n",