From patchwork Thu Mar 29 09:10:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 892649 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=kaod.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40BfDq5nmRz9s0q for ; Thu, 29 Mar 2018 20:13:31 +1100 (AEDT) Received: from localhost ([::1]:60866 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f1Tcf-0004Ic-CN for incoming@patchwork.ozlabs.org; Thu, 29 Mar 2018 05:13:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33589) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f1TZs-0002Bo-Hw for qemu-devel@nongnu.org; Thu, 29 Mar 2018 05:10:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f1TZo-0006HA-H7 for qemu-devel@nongnu.org; Thu, 29 Mar 2018 05:10:36 -0400 Received: from 6.mo5.mail-out.ovh.net ([178.32.119.138]:49961) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f1TZo-0006Gr-BS for qemu-devel@nongnu.org; Thu, 29 Mar 2018 05:10:32 -0400 Received: from player728.ha.ovh.net (unknown [10.109.120.119]) by mo5.mail-out.ovh.net (Postfix) with ESMTP id AFBB119A308 for ; Thu, 29 Mar 2018 11:10:30 +0200 (CEST) Received: from bahia.lan (lns-bzn-46-82-253-208-248.adsl.proxad.net [82.253.208.248]) (Authenticated sender: groug@kaod.org) by player728.ha.ovh.net (Postfix) with ESMTPA id 4245754008F; Thu, 29 Mar 2018 11:10:21 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Thu, 29 Mar 2018 11:10:21 +0200 Message-ID: <152231462116.69730.14119625999092384450.stgit@bahia.lan> In-Reply-To: <152231456507.69730.15601462044394150786.stgit@bahia.lan> References: <152231456507.69730.15601462044394150786.stgit@bahia.lan> User-Agent: StGit/0.17.1-46-g6855-dirty MIME-Version: 1.0 X-Ovh-Tracer-Id: 12503681418255636822 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtgedrfedvgdduudcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 178.32.119.138 Subject: [Qemu-devel] [PATCH 3/3] sev/i386: fix memory leak in sev_guest_init() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Crosthwaite , Eduardo Habkost , David Hildenbrand , Cornelia Huck , Alexander Graf , qemu-stable@nongnu.org, qemu-s390x@nongnu.org, Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The string returned by object_property_get_str() is dynamically allocated. Fixes: d8575c6c0242b Signed-off-by: Greg Kurz Reviewed-by: Cornelia Huck Reviewed-by: Thomas Huth --- 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 019d84cef2c7..c01167143f1c 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);