From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 964B468CF for ; Mon, 20 Jun 2016 12:50:02 +0200 (CEST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP; 20 Jun 2016 03:49:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,497,1459839600"; d="scan'208";a="125222250" Received: from yliu-dev.sh.intel.com ([10.239.67.162]) by fmsmga004.fm.intel.com with ESMTP; 20 Jun 2016 03:49:47 -0700 From: Yuanhan Liu To: dev@dpdk.org Cc: huawei.xie@intel.com, Yuanhan Liu , Remy Horton Date: Mon, 20 Jun 2016 18:50:43 +0800 Message-Id: <1466419843-1321-1-git-send-email-yuanhan.liu@linux.intel.com> X-Mailer: git-send-email 1.9.0 Subject: [dpdk-dev] [PATCH] virtio: fix crash on querying xstats X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Jun 2016 10:50:03 -0000 Trying to access xstats_names after "if (stats_names == NULL)" is obviously wrong, which would result to a crash while running "show port xstats 0" in testpmd with virtio PMD. The fix is also straightforward: just revese the check. Fixes: baf91c395b18 ("net/virtio: fetch extended statistics with integer ids") Cc: Remy Horton Signed-off-by: Yuanhan Liu --- drivers/net/virtio/virtio_ethdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index 19d5d8a..12fa640 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -776,7 +776,7 @@ static int virtio_dev_xstats_get_names(struct rte_eth_dev *dev, unsigned nstats = dev->data->nb_tx_queues * VIRTIO_NB_TXQ_XSTATS + dev->data->nb_rx_queues * VIRTIO_NB_RXQ_XSTATS; - if (xstats_names == NULL) { + if (xstats_names != NULL) { /* Note: limit checked in rte_eth_xstats_names() */ for (i = 0; i < dev->data->nb_rx_queues; i++) { -- 1.9.0