From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by dpdk.org (Postfix) with ESMTP id 512E62B8B for ; Thu, 1 Feb 2018 10:49:15 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 0C0592076C; Thu, 1 Feb 2018 04:49:15 -0500 (EST) Received: from frontend2 ([10.202.2.161]) by compute1.internal (MEProxy); Thu, 01 Feb 2018 04:49:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fridaylinux.org; h=cc:date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=zjin2GH3SsvidJ8ks +vDqk5KCf0bXFp8PBnzycc2Z1g=; b=EHXT20AKdwLADX0kiiU7NAP5ZmmQxvTMD /MeKuN3Y5TXVbD2gvfwkOv00SltgMby8ymxMaEvmM7dWWAUNb7Mfq2xbtEtQT/Ly 2+ZSgW/NR0s6pUCa5LsSRzAqOji85TmiHDmV6NcRXy4JhN5GRl7HpPgdZCqQ8HWH lLbZKFkho+ydyNu8dOdtC3M9BOy8FGF/c60EmGKw5bLRPiiQCejhOB/HamlKhBHY DO/6UmoG+4nWIcb5jKMMnyxhF331I25I6nPGCiScSnmUzFhh0m1o78KMUEcTydI8 n7g16tNibnJT9y9offHox8u/1BBlpqrbx2yHnTZMeb8DkET4tlxRA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=zjin2GH3SsvidJ8ks+vDqk5KCf0bXFp8PBnzycc2Z1g=; b=YzgaBUco hEYHd39Thi/7Hvoraoj4EU7Blpl1Mlfs4Yg0Up27yZd8YjbctmvGBWsN4PhTuQOP xr5dfbr7iz7iUQ2On+Q6n0HR61A08ciRwKFRD5sjD5jj9eBN7cpyR8Dcvh05uusu 74p2zF6nnenl89RniNdtCwX7NN/QRQFmbRMvB0pUOB656urNFox2qca7RskjCNYg oyP7e++LyGvmumarYCO5snEhF+uJvevLUIa6cGw9m7ayWeDA4hz3zDhg4vloEnGB 1KHryUNwnLJehA5JY2JscVJsRKwIov7jT+y+I58WMinmtRe9jVo9Q0ZUcbcLTPQR syR8HFVBNnromQ== X-ME-Sender: Received: from yliu-mob.mtl.com (unknown [115.150.27.200]) by mail.messagingengine.com (Postfix) with ESMTPA id 478EE240B6; Thu, 1 Feb 2018 04:49:11 -0500 (EST) From: Yuanhan Liu To: Olivier Matz Cc: Zijie Pan , Yuanhan Liu , dpdk stable Date: Thu, 1 Feb 2018 17:47:40 +0800 Message-Id: <1517478479-12417-26-git-send-email-yliu@fridaylinux.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517478479-12417-1-git-send-email-yliu@fridaylinux.org> References: <1517478479-12417-1-git-send-email-yliu@fridaylinux.org> Subject: [dpdk-stable] patch 'net/virtio: fix memory leak when reinitializing device' has been queued to LTS release 17.11.1 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Feb 2018 09:49:15 -0000 Hi, FYI, your patch has been queued to LTS release 17.11.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 02/03/18. So please shout if anyone has objections. Thanks. --yliu --- >>From f0d46b0954b72cc25147bec8391dd540c47c5731 Mon Sep 17 00:00:00 2001 From: Olivier Matz Date: Tue, 23 Jan 2018 16:54:41 +0100 Subject: [PATCH] net/virtio: fix memory leak when reinitializing device [ upstream commit 3669a1af893088064778f14fba0c2ca88819e095 ] Free the previous queues and the attached mbufs before initializing new ones. The function virtio_dev_free_mbufs() is now called when reconfiguring the device, so we also need to add a check to ensure that it won't crash for uninitialized queues. Fixes: 60e6f4707ef2 ("net/virtio: reinitialize device when configuring") Signed-off-by: Zijie Pan Signed-off-by: Olivier Matz Acked-by: Yuanhan Liu --- drivers/net/virtio/virtio_ethdev.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index 74e3c24..4da1ba3 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -1394,6 +1394,11 @@ virtio_init_device(struct rte_eth_dev *eth_dev, uint64_t req_features) /* Reset the device although not necessary at startup */ vtpci_reset(hw); + if (hw->vqs) { + virtio_dev_free_mbufs(eth_dev); + virtio_free_queues(hw); + } + /* Tell the host we've noticed this device. */ vtpci_set_status(hw, VIRTIO_CONFIG_STATUS_ACK); @@ -1887,6 +1892,9 @@ static void virtio_dev_free_mbufs(struct rte_eth_dev *dev) for (i = 0; i < dev->data->nb_rx_queues; i++) { struct virtnet_rx *rxvq = dev->data->rx_queues[i]; + if (rxvq == NULL || rxvq->vq == NULL) + continue; + PMD_INIT_LOG(DEBUG, "Before freeing rxq[%d] used and unused buf", i); VIRTQUEUE_DUMP(rxvq->vq); @@ -1906,6 +1914,9 @@ static void virtio_dev_free_mbufs(struct rte_eth_dev *dev) for (i = 0; i < dev->data->nb_tx_queues; i++) { struct virtnet_tx *txvq = dev->data->tx_queues[i]; + if (txvq == NULL || txvq->vq == NULL) + continue; + PMD_INIT_LOG(DEBUG, "Before freeing txq[%d] used and unused bufs", i); -- 2.7.4