From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 892D35323; Sun, 22 Jan 2017 09:44:50 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga105.jf.intel.com with ESMTP; 22 Jan 2017 00:44:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,268,1477983600"; d="scan'208";a="33807496" Received: from yliu-dev.sh.intel.com ([10.239.67.162]) by orsmga002.jf.intel.com with ESMTP; 22 Jan 2017 00:44:38 -0800 From: Yuanhan Liu To: dev@dpdk.org Cc: Yuanhan Liu , stable@dpdk.org Date: Sun, 22 Jan 2017 16:47:00 +0800 Message-Id: <1485074820-8956-4-git-send-email-yuanhan.liu@linux.intel.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1485074820-8956-1-git-send-email-yuanhan.liu@linux.intel.com> References: <1485074820-8956-1-git-send-email-yuanhan.liu@linux.intel.com> Subject: [dpdk-dev] [PATCH 3/3] net/virtio: fix crash when number of virtio devices > 1 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: , X-List-Received-Date: Sun, 22 Jan 2017 08:44:51 -0000 The vtpci_ops assignment needs the 'hw->port_id' as an input parameter. That said, we should set 'hw->port_id' firstly, then do the vtpci_ops assignment, while the code does reversely. That would result to a crash when more than one virtio devices are used, because we keep assigning proper vtpci_ops to virtio_hw_internal[0]->vtpci_ops, leaving the pointer for other ports being NULL. Reverse the order fixes this issue. Fixes: 9470427c88e1 ("net/virtio: do not store PCI device pointer at shared memory") Cc: stable@dpdk.org Reported-by: Lei Yao 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 1d51942..68dde08 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -1515,6 +1515,7 @@ static int virtio_dev_xstats_get_names(struct rte_eth_dev *dev, return -ENOMEM; } + hw->port_id = eth_dev->data->port_id; /* For virtio_user case the hw->virtio_user_dev is populated by * virtio_user_eth_dev_alloc() before eth_virtio_dev_init() is called. */ @@ -1525,7 +1526,6 @@ static int virtio_dev_xstats_get_names(struct rte_eth_dev *dev, return ret; } - hw->port_id = eth_dev->data->port_id; eth_dev->data->dev_flags = dev_flags; /* reset device and negotiate default features */ -- 1.9.0