From 5d7bc72a4336f922ba42bab545529051c706ac4b Mon Sep 17 00:00:00 2001 From: Greg Kurz Date: Thu, 29 Mar 2018 11:10:21 +0200 Subject: [PATCH] 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);