From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from m15-112.126.com (m15-112.126.com [220.181.15.112]) by dpdk.org (Postfix) with ESMTP id EDC6C58F6 for ; Mon, 20 Feb 2017 15:08:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id; bh=TeEN/4kaK6W8tLmevi oXsTqWcpu0FjWQncPuZx8X3DM=; b=BEzBgSVwzNmDODATPlO1B8+acipmMVjgf4 K+atDmkV5jLpsciMqFLu06ceQajR95gBZ1iSn8ENgI0yq7w2DfZK0HVKDyYFTGj1 3RdxkBDJTJu9Nf10QhR7o5s5Ki4RMLw7Uow98t6KStIR24lV11HgtrGHk9IxcEOF QesaqZlMQ= Received: from localhost.localdomain (unknown [183.247.84.222]) by smtp2 (Coremail) with SMTP id DMmowACHfKUr+KpYKDzUCw--.5393S4; Mon, 20 Feb 2017 22:07:58 +0800 (CST) From: hanxueluo@126.com To: dev@dpdk.org Cc: Huanle Han Date: Mon, 20 Feb 2017 22:04:46 +0800 Message-Id: <1487599487-12574-2-git-send-email-hanxueluo@126.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487599487-12574-1-git-send-email-hanxueluo@126.com> References: <1487599487-12574-1-git-send-email-hanxueluo@126.com> X-CM-TRANSID: DMmowACHfKUr+KpYKDzUCw--.5393S4 X-Coremail-Antispam: 1Uf129KBjvJXoW7Ar1xtw17KryxAF4Dtr4rAFb_yoW8XrWDpF WDCF43tF17JFnFqan3Ca1I9Fy5uan7trW7K34xZ3s8C345ZrW7WryUAry09rs2y3yDCr4U Ar409r4qqFWDuF7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jVksDUUUUU= X-Originating-IP: [183.247.84.222] X-CM-SenderInfo: xkdq53phox0qqrswhudrp/1tbimh6E51ag1aBkcAAAsw Subject: [dpdk-dev] [PATCH 2/3] net/virtio: fix crash when close virtio dev twice 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: Mon, 20 Feb 2017 14:08:05 -0000 From: Huanle Han This commit fixs segment fault when rte_eth_dev_close() is called on a virtio dev more than once. Assigning zero after free to avoids freed memory to be accessed again. Signed-off-by: Huanle Han --- drivers/net/virtio/virtio_ethdev.c | 5 +++++ lib/librte_ether/rte_ethdev.c | 2 ++ 2 files changed, 7 insertions(+) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index 8465e1a..b9565db 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -545,6 +545,9 @@ virtio_free_queues(struct virtio_hw *hw) int queue_type; uint16_t i; + if (hw->vqs == NULL) + return; + for (i = 0; i < nr_vq; i++) { vq = hw->vqs[i]; if (!vq) @@ -563,9 +566,11 @@ virtio_free_queues(struct virtio_hw *hw) } rte_free(vq); + hw->vqs[i] = NULL; } rte_free(hw->vqs); + hw->vqs = NULL; } static int diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index eb0a94a..24f82dc 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -1074,8 +1074,10 @@ rte_eth_dev_close(uint8_t port_id) dev->data->dev_started = 0; (*dev->dev_ops->dev_close)(dev); + dev->data->nb_rx_queues = 0; rte_free(dev->data->rx_queues); dev->data->rx_queues = NULL; + dev->data->nb_tx_queues = 0; rte_free(dev->data->tx_queues); dev->data->tx_queues = NULL; } -- 2.7.4