* [dpdk-stable] [PATCH 1/2] vhost: fix memory leak on realloc failure
[not found] <20190114033444.13026-1-tiwei.bie@intel.com>
@ 2019-01-14 3:34 ` Tiwei Bie
2019-01-14 10:20 ` Maxime Coquelin
2019-01-14 3:34 ` [dpdk-stable] [PATCH 2/2] examples/vhost: fix " Tiwei Bie
1 sibling, 1 reply; 6+ messages in thread
From: Tiwei Bie @ 2019-01-14 3:34 UTC (permalink / raw)
To: maxime.coquelin, zhihong.wang, dev; +Cc: stable
When realloc() fails, the original block isn't freed.
Fixes: e246896178e6 ("vhost: get guest/host physical address mappings")
Cc: stable@dpdk.org
Signed-off-by: Tiwei Bie <tiwei.bie@intel.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 8fec773d5..5222f77dd 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -730,13 +730,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.17.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [dpdk-stable] [PATCH 2/2] examples/vhost: fix realloc failure
[not found] <20190114033444.13026-1-tiwei.bie@intel.com>
2019-01-14 3:34 ` [dpdk-stable] [PATCH 1/2] vhost: fix memory leak on realloc failure Tiwei Bie
@ 2019-01-14 3:34 ` Tiwei Bie
2019-01-14 10:20 ` Maxime Coquelin
2019-01-15 1:56 ` Thomas Monjalon
1 sibling, 2 replies; 6+ messages in thread
From: Tiwei Bie @ 2019-01-14 3:34 UTC (permalink / raw)
To: maxime.coquelin, zhihong.wang, dev; +Cc: stable
Fixes: ad0eef4d2203 ("examples/vhost: support multiple socket files")
Cc: stable@dpdk.org
Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
---
examples/vhost/main.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index dc9ea1018..23fee445a 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -375,11 +375,19 @@ port_init(uint16_t port)
static int
us_vhost_parse_socket_path(const char *q_arg)
{
+ char *old;
+
/* parse number string */
if (strnlen(q_arg, PATH_MAX) == PATH_MAX)
return -1;
+ old = socket_files;
socket_files = realloc(socket_files, PATH_MAX * (nb_sockets + 1));
+ if (socket_files == NULL) {
+ free(old);
+ return -1;
+ }
+
snprintf(socket_files + nb_sockets * PATH_MAX, PATH_MAX, "%s", q_arg);
nb_sockets++;
--
2.17.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-stable] [PATCH 1/2] vhost: fix memory leak on realloc failure
2019-01-14 3:34 ` [dpdk-stable] [PATCH 1/2] vhost: fix memory leak on realloc failure Tiwei Bie
@ 2019-01-14 10:20 ` Maxime Coquelin
0 siblings, 0 replies; 6+ messages in thread
From: Maxime Coquelin @ 2019-01-14 10:20 UTC (permalink / raw)
To: Tiwei Bie, zhihong.wang, dev; +Cc: stable
On 1/14/19 4:34 AM, Tiwei Bie wrote:
> When realloc() fails, the original block isn't freed.
>
> Fixes: e246896178e6 ("vhost: get guest/host physical address mappings")
> Cc: stable@dpdk.org
>
> Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
> ---
> lib/librte_vhost/vhost_user.c | 3 +++
> 1 file changed, 3 insertions(+)
>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Thanks,
Maxime
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-stable] [PATCH 2/2] examples/vhost: fix realloc failure
2019-01-14 3:34 ` [dpdk-stable] [PATCH 2/2] examples/vhost: fix " Tiwei Bie
@ 2019-01-14 10:20 ` Maxime Coquelin
2019-01-15 1:56 ` Thomas Monjalon
1 sibling, 0 replies; 6+ messages in thread
From: Maxime Coquelin @ 2019-01-14 10:20 UTC (permalink / raw)
To: Tiwei Bie, zhihong.wang, dev; +Cc: stable
On 1/14/19 4:34 AM, Tiwei Bie wrote:
> Fixes: ad0eef4d2203 ("examples/vhost: support multiple socket files")
> Cc: stable@dpdk.org
>
> Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
> ---
> examples/vhost/main.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Thanks,
Maxime
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-stable] [PATCH 2/2] examples/vhost: fix realloc failure
2019-01-14 3:34 ` [dpdk-stable] [PATCH 2/2] examples/vhost: fix " Tiwei Bie
2019-01-14 10:20 ` Maxime Coquelin
@ 2019-01-15 1:56 ` Thomas Monjalon
2019-01-15 6:53 ` Tiwei Bie
1 sibling, 1 reply; 6+ messages in thread
From: Thomas Monjalon @ 2019-01-15 1:56 UTC (permalink / raw)
To: Tiwei Bie; +Cc: stable, maxime.coquelin, zhihong.wang, dev
14/01/2019 04:34, Tiwei Bie:
> Fixes: ad0eef4d2203 ("examples/vhost: support multiple socket files")
> Cc: stable@dpdk.org
Please add some explanations about what was wrong.
About the title, do you mean "fix path allocation failure handling" ?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-stable] [PATCH 2/2] examples/vhost: fix realloc failure
2019-01-15 1:56 ` Thomas Monjalon
@ 2019-01-15 6:53 ` Tiwei Bie
0 siblings, 0 replies; 6+ messages in thread
From: Tiwei Bie @ 2019-01-15 6:53 UTC (permalink / raw)
To: Thomas Monjalon; +Cc: stable, maxime.coquelin, zhihong.wang, dev
On Tue, Jan 15, 2019 at 02:56:39AM +0100, Thomas Monjalon wrote:
> 14/01/2019 04:34, Tiwei Bie:
> > Fixes: ad0eef4d2203 ("examples/vhost: support multiple socket files")
> > Cc: stable@dpdk.org
>
> Please add some explanations about what was wrong.
My bad. Will do it in the next version.
>
> About the title, do you mean "fix path allocation failure handling" ?
Yeah, thanks for the suggestion!
Thanks
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-01-15 6:56 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20190114033444.13026-1-tiwei.bie@intel.com>
2019-01-14 3:34 ` [dpdk-stable] [PATCH 1/2] vhost: fix memory leak on realloc failure Tiwei Bie
2019-01-14 10:20 ` Maxime Coquelin
2019-01-14 3:34 ` [dpdk-stable] [PATCH 2/2] examples/vhost: fix " Tiwei Bie
2019-01-14 10:20 ` Maxime Coquelin
2019-01-15 1:56 ` Thomas Monjalon
2019-01-15 6:53 ` Tiwei Bie
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).