[dpdk-stable] patch 'net/virtio: fix memory leak when reinitializing device' has been queued to LTS release 17.11.1
Yuanhan Liu
yliu at fridaylinux.org
Thu Feb 1 10:47:40 CET 2018
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 <olivier.matz at 6wind.com>
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 <zijie.pan at 6wind.com>
Signed-off-by: Olivier Matz <olivier.matz at 6wind.com>
Acked-by: Yuanhan Liu <yliu at fridaylinux.org>
---
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
More information about the stable
mailing list