summaryrefslogtreecommitdiff
path: root/lib/librte_vhost
diff options
context:
space:
mode:
authorIlya Maximets <i.maximets@samsung.com>2018-08-15 17:54:39 +0300
committerFerruh Yigit <ferruh.yigit@intel.com>2018-09-12 19:10:09 +0200
commit28925156d91bedb8f4b85b10dd9f3303a4d9e759 (patch)
treef341c2523ddf6ba720babb414d25491594bad582 /lib/librte_vhost
parentb24ec9bc1c43f7cada0b16709043f84f52f2b895 (diff)
downloaddpdk-28925156d91bedb8f4b85b10dd9f3303a4d9e759.zip
dpdk-28925156d91bedb8f4b85b10dd9f3303a4d9e759.tar.gz
dpdk-28925156d91bedb8f4b85b10dd9f3303a4d9e759.tar.xz
vhost: fix zmbufs array leak after NUMA realloc
'numa_realloc()' allocates 'zmbufs' even if zero copy mode is not configured. This leads to memory leak, because array is freed only for zero copy case. Fixes: 2651726defb7 ("vhost: do deep copy while reallocating queue") CC: stable@dpdk.org Signed-off-by: Ilya Maximets <i.maximets@samsung.com> Reviewed-by: Tiwei Bie <tiwei.bie@intel.com>
Diffstat (limited to 'lib/librte_vhost')
-rw-r--r--lib/librte_vhost/vhost_user.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index a2d4c9f..9aa1ce1 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -357,11 +357,13 @@ numa_realloc(struct virtio_net *dev, int index)
memcpy(vq, old_vq, sizeof(*vq));
TAILQ_INIT(&vq->zmbuf_list);
- new_zmbuf = rte_malloc_socket(NULL, vq->zmbuf_size *
- sizeof(struct zcopy_mbuf), 0, newnode);
- if (new_zmbuf) {
- rte_free(vq->zmbufs);
- vq->zmbufs = new_zmbuf;
+ if (dev->dequeue_zero_copy) {
+ new_zmbuf = rte_malloc_socket(NULL, vq->zmbuf_size *
+ sizeof(struct zcopy_mbuf), 0, newnode);
+ if (new_zmbuf) {
+ rte_free(vq->zmbufs);
+ vq->zmbufs = new_zmbuf;
+ }
}
if (vq_is_packed(dev)) {