From 72a841d2a403b56ff894fa007b172dc9bcb3dae8 Mon Sep 17 00:00:00 2001 From: Greg Kurz Date: Thu, 29 Mar 2018 11:09:46 +0200 Subject: [PATCH 1/2] exec: fix memory leak in find_max_supported_pagesize() The string returned by object_property_get_str() is dynamically allocated. Signed-off-by: Greg Kurz Message-Id: <152231458624.69730.1752893648612848392.stgit@bahia.lan> Reviewed-by: Cornelia Huck Reviewed-by: Thomas Huth Signed-off-by: Eduardo Habkost --- exec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/exec.c b/exec.c index c09bd93df3..02b1efebb7 100644 --- a/exec.c +++ b/exec.c @@ -1495,6 +1495,7 @@ static int find_max_supported_pagesize(Object *obj, void *opaque) mem_path = object_property_get_str(obj, "mem-path", NULL); if (mem_path) { long hpsize = qemu_mempath_getpagesize(mem_path); + g_free(mem_path); if (hpsize < *hpsize_min) { *hpsize_min = hpsize; } From 5d7bc72a4336f922ba42bab545529051c706ac4b Mon Sep 17 00:00:00 2001 From: Greg Kurz Date: Thu, 29 Mar 2018 11:10:21 +0200 Subject: [PATCH 2/2] sev/i386: fix memory leak in sev_guest_init() The string returned by object_property_get_str() is dynamically allocated. Fixes: d8575c6c0242b Signed-off-by: Greg Kurz Message-Id: <152231462116.69730.14119625999092384450.stgit@bahia.lan> Reviewed-by: Cornelia Huck Reviewed-by: Thomas Huth Signed-off-by: Eduardo Habkost --- target/i386/sev.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/target/i386/sev.c b/target/i386/sev.c index 019d84cef2..c01167143f 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -748,9 +748,11 @@ sev_guest_init(const char *id) if (s->sev_fd < 0) { error_report("%s: Failed to open %s '%s'", __func__, devname, strerror(errno)); - goto err; } g_free(devname); + if (s->sev_fd < 0) { + goto err; + } ret = sev_platform_ioctl(s->sev_fd, SEV_PLATFORM_STATUS, &status, &fw_error);