From nobody Fri Apr 19 22:21:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1589631800; cv=none; d=zohomail.com; s=zohoarc; b=RL3buZLQVkCg90IvyJb7hCqGiPMG14MKgXHbwXosjUkKz803txHGzEoV2t+gtUF4MBvAfT/13QrGlQswrVHPEMs28ryFTL8mQnSX3Nde5aRXB2SPvXI3TmYgNrt9EyjjL+/gSD5dTSKw29bmsHS9Pr6BpAMmmLH/8QRlo8OkCwg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589631800; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=ACDMqf8YxY2PDXVWnHlM9QOYMZXRgbtJPExmKeIm62k=; b=IwkZHv7FUXESQVtJY8CZVTuos569lT2BBh2MidTJ5Aj0BZYWS2VbB918ks8jEaxKJNcJF8bKaFOnRBrPpPOVzb+uN7fKQD1PIgBhvKtbgNVtMEysfYvDr+r0J/r9a0pyVKM4w6XFsrgbbpVnrXPoMq6gTPeorlunEKbWt+y5RdI= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1589631800409596.571856501122; Sat, 16 May 2020 05:23:20 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jZvpz-0001a2-EM; Sat, 16 May 2020 12:22:43 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jZvpy-0001Zx-NK for xen-devel@lists.xenproject.org; Sat, 16 May 2020 12:22:42 +0000 Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id eff7eeea-976f-11ea-b07b-bc764e2007e4; Sat, 16 May 2020 12:22:41 +0000 (UTC) X-Inumbo-ID: eff7eeea-976f-11ea-b07b-bc764e2007e4 Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: 7gniSrxD044gQrv0A2IdFq/CQ6dICUMU3MO34jajP54ad8PV7+kNE95XKhEWNHCc776SeKjHOh PZhSj8hJvacu3IvAtcxIoAaZ0AACf7cv+c3HSNZEvApQURFV/Lc7sxQaYDwR3PAVlwlKmNFm0J lDEcqygUH4v7bXvrVGDjdQL6edovO0dcoxMAsbIGEjO88wfKeRaE/N6ey9af1VoBgae++QBfnh g4mZtvvCgSMM0tRsfUJYlySbIiRp1jWuFu9XyOrNZj58N44dQCx+JCf/qCFXtPOIPODLV94UIq QxE= X-SBRS: 2.7 X-MesageID: 17694874 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.73,398,1583211600"; d="scan'208";a="17694874" From: Andrew Cooper To: Xen-devel Subject: [PATCH] x86/hvm: Fix memory leaks in hvm_copy_context_and_params() Date: Sat, 16 May 2020 13:22:21 +0100 Message-ID: <20200516122221.5434-1-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Tamas K Lengyel , Wei Liu , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Any error from hvm_save() or hvm_set_param() leaks the c.data allocation. Spotted by Coverity. Fixes: 353744830 "x86/hvm: introduce hvm_copy_context_and_params" Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monn=C3=A9 CC: Tamas K Lengyel This was the XenServer internal Coverity. The public one doesn't appear to have spotted the issue, so no Coverity-ID tag for the fix. --- xen/arch/x86/hvm/hvm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 814b7020d8..0a3797ef6e 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -5318,7 +5318,7 @@ int hvm_copy_context_and_params(struct domain *dst, s= truct domain *src) return -ENOMEM; =20 if ( (rc =3D hvm_save(src, &c)) ) - return rc; + goto out; =20 for ( i =3D 0; i < HVM_NR_PARAMS; i++ ) { @@ -5328,11 +5328,13 @@ int hvm_copy_context_and_params(struct domain *dst,= struct domain *src) continue; =20 if ( (rc =3D hvm_set_param(dst, i, value)) ) - return rc; + goto out; } =20 c.cur =3D 0; rc =3D hvm_load(dst, &c); + + out: vfree(c.data); =20 return rc; --=20 2.11.0