vhost: fix a memory leak
PATCH 1/1 vhost: fix a memory leak
vhost exists a call for g_file_get_contents, but not call g_free.
--- hw/virtio/vhost-backend.c | 2 ++ 1 file changed, 2 insertions(+)
hw/virtio/vhost-backend.c +2 -0
@@ -52,11 +52,13 @@ static int vhost_kernel_memslots_limit(struct vhost_dev *dev) &s, NULL, NULL)) {uint64_t val =g_ascii_strtoull (s,NULL ,10 );if (!((val ==G_MAXUINT64 || !val) && errno)) { +g_free (s);return val; }error_report ("ignoring invalid max_mem_regions value in vhost module:" " %s" , s); } +g_free (s);return limit; }
Signature · 1 line
1.8.3.1
Hi
Quoted 4 lines · Peng Hao
vhost exists a call for
g_file_get_contents, but not callg_free.Signed-off-by Peng Hao<[email protected]>
---
Quoted 21 lines
hw/virtio/vhost-backend.c | 2 ++ 1 file changed, 2 insertions(+)hw/virtio/vhost-backend.c +1
-0@@ -52,11 +52,13 @@ static int vhost_kernel_memslots_limit(struct vhost_dev *dev) &s, NULL, NULL)) {uint64_t val =g_ascii_strtoull (s,NULL ,10 );if (!((val ==G_MAXUINT64 || !val) && errno)) { +g_free (s);return val; } error_report("ignoring invalid max_mem_regions value in vhostmodule:"
" %s", s); } + g_free(s); return limit;
Quoted 8 lines
}
--
1.8.3.1--
Marc-André Lureau
Quoted 30 lines · Marc-André Lureau
Hi
On Tue, Jul 4, 2017 at 4:16 PM Peng Hao <[email protected]> wrote:
vhost exists a call for
g_file_get_contents, but not callg_free.Signed-off-by Peng Hao<[email protected]>Reviewed-by Marc-André Lureau <[email protected]>--- hw/virtio/vhost-backend.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c index 4e31de1..2c481d6 100644 --- a/hw/virtio/vhost-backend.c +++ b/hw/virtio/vhost-backend.c @@ -52,11 +52,13 @@ static int vhost_kernel_memslots_limit(struct vhost_dev *dev) &s, NULL, NULL)) { uint64_t val = g_ascii_strtoull(s, NULL, 10); if (!((val == G_MAXUINT64 || !val) && errno)) { + g_free(s); return val; } error_report("ignoring invalid max_mem_regions value in vhost module:"
Quoted 9 lines
" %s", s);
}
+ g_free(s);
return limit;
}
--
1.8.3.1Thanks for the review.
I'd like to include your tag in commit log.
For that, could you please repost your ack in text format using some other mail client?
My scripts don't handle the way your mail client scrambles text.
Quoted 4 lines
--
Marc-André Lureau
Hi
Quoted 3 lines · Peng Hao
vhost exists a call for
g_file_get_contents, but not callg_free.Signed-off-by Peng Hao<[email protected]>
mst: is this better?
Quoted 27 lines
--- hw/virtio/vhost-backend.c | 2 ++ 1 file changed, 2 insertions(+)hw/virtio/vhost-backend.c +2
-1@@ -52,11 +52,13 @@ static int vhost_kernel_memslots_limit(struct vhost_dev *dev) &s, NULL, NULL)) {uint64_t val =g_ascii_strtoull (s,NULL ,10 );if (!((val ==G_MAXUINT64 || !val) && errno)) { +g_free (s);return val; }error_report ("ignoring invalid max_mem_regions value in vhost module:" " %s" , s); } +g_free (s);return limit; } --1.8.3.1
Signature · 1 line
Marc-André Lureau
Quoted 10 lines · Marc-André Lureau
Hi
Quoted 3 lines · Peng Hao
vhost exists a call for
g_file_get_contents, but not callg_free.Signed-off-by Peng Hao<[email protected]>Reviewed-by Marc-André Lureau <[email protected]>mst: is this better?
That's fine, thanks!
Quoted 32 lines
Quoted 27 lines
--- hw/virtio/vhost-backend.c | 2 ++ 1 file changed, 2 insertions(+)hw/virtio/vhost-backend.c +2
-1@@ -52,11 +52,13 @@ static int vhost_kernel_memslots_limit(struct vhost_dev *dev) &s, NULL, NULL)) {uint64_t val =g_ascii_strtoull (s,NULL ,10 );if (!((val ==G_MAXUINT64 || !val) && errno)) { +g_free (s);return val; }error_report ("ignoring invalid max_mem_regions value in vhost module:" " %s" , s); } +g_free (s);return limit; } --1.8.3.1
Signature · 1 line
Marc-André Lureau