[dpdk-stable] patch 'vhost: fix memory leak on realloc failure' has been queued to LTS release 17.11.6

Yongseok Koh yskoh at mellanox.com
Fri Mar 8 18:47:32 CET 2019


Hi,

FYI, your patch has been queued to LTS release 17.11.6

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objection by 03/13/19. So please
shout if anyone has objection.

Also note that after the patch there's a diff of the upstream commit vs the patch applied
to the branch. If the code is different (ie: not only metadata diffs), due for example to
a change in context or macro names, please double check it.

Thanks.

Yongseok

---
>From e4b5a49bbad8abbb10b772f78f29ff8f7ef00248 Mon Sep 17 00:00:00 2001
From: Tiwei Bie <tiwei.bie at intel.com>
Date: Tue, 15 Jan 2019 15:13:23 +0800
Subject: [PATCH] vhost: fix memory leak on realloc failure

[ upstream commit e1c0834f95597b1d5a889532281eb2fde6774ddd ]

When realloc() fails, the original block isn't freed.

Fixes: e246896178e6 ("vhost: get guest/host physical address mappings")

Signed-off-by: Tiwei Bie <tiwei.bie at intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin at redhat.com>
---
 lib/librte_vhost/vhost_user.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index aacf75b13..61e82d154 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -510,13 +510,16 @@ add_one_guest_page(struct virtio_net *dev, uint64_t guest_phys_addr,
 		   uint64_t host_phys_addr, uint64_t size)
 {
 	struct guest_page *page, *last_page;
+	struct guest_page *old_pages;
 
 	if (dev->nr_guest_pages == dev->max_guest_pages) {
 		dev->max_guest_pages *= 2;
+		old_pages = dev->guest_pages;
 		dev->guest_pages = realloc(dev->guest_pages,
 					dev->max_guest_pages * sizeof(*page));
 		if (!dev->guest_pages) {
 			RTE_LOG(ERR, VHOST_CONFIG, "cannot realloc guest_pages\n");
+			free(old_pages);
 			return -1;
 		}
 	}
-- 
2.11.0

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2019-03-08 09:46:42.879871570 -0800
+++ 0054-vhost-fix-memory-leak-on-realloc-failure.patch	2019-03-08 09:46:40.279403000 -0800
@@ -1,12 +1,13 @@
-From e1c0834f95597b1d5a889532281eb2fde6774ddd Mon Sep 17 00:00:00 2001
+From e4b5a49bbad8abbb10b772f78f29ff8f7ef00248 Mon Sep 17 00:00:00 2001
 From: Tiwei Bie <tiwei.bie at intel.com>
 Date: Tue, 15 Jan 2019 15:13:23 +0800
 Subject: [PATCH] vhost: fix memory leak on realloc failure
 
+[ upstream commit e1c0834f95597b1d5a889532281eb2fde6774ddd ]
+
 When realloc() fails, the original block isn't freed.
 
 Fixes: e246896178e6 ("vhost: get guest/host physical address mappings")
-Cc: stable at dpdk.org
 
 Signed-off-by: Tiwei Bie <tiwei.bie at intel.com>
 Reviewed-by: Maxime Coquelin <maxime.coquelin at redhat.com>
@@ -15,10 +16,10 @@
  1 file changed, 3 insertions(+)
 
 diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
-index f2f30369b..78be6cfa5 100644
+index aacf75b13..61e82d154 100644
 --- a/lib/librte_vhost/vhost_user.c
 +++ b/lib/librte_vhost/vhost_user.c
-@@ -733,13 +733,16 @@ add_one_guest_page(struct virtio_net *dev, uint64_t guest_phys_addr,
+@@ -510,13 +510,16 @@ add_one_guest_page(struct virtio_net *dev, uint64_t guest_phys_addr,
  		   uint64_t host_phys_addr, uint64_t size)
  {
  	struct guest_page *page, *last_page;


More information about the stable mailing list