From nobody Fri Oct 31 03:42:56 2025 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; dkim=pass; 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=pass(p=quarantine dis=none) header.from=proton.me ARC-Seal: i=1; a=rsa-sha256; t=1750641428; cv=none; d=zohomail.com; s=zohoarc; b=m5HhlpPL1YQlxsQWTDosUq5dgw2korhy2E9AbZ5E+q7Fz6bWOzf6fwQbdOGrcmJBRMOX4VJY0ipMGm9W7g4QY+eM8EWHa7pv881nf4IlQUKBX6iZRcTbWMztCw+6dwuZ9dQsLoJ9Pz7T0V10TDMTlQAMm8ecKl2Q/pedVIRG6Vc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750641428; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=PMAd4zFxcXv5vGZUSDMj0BvN3PyFw2OdCgQnVuQcNh0=; b=a8rmyJTE18gc5Ej14c4CQVEmOWn9HJhVUsZ3I4DedbPrePC8EyS7qc7Y6ckR/DZc+Le4iLzfxRPkfhF35nMba2Q6v9vO1F/iz+uds9XONIsJ7aQ8Cb1gxB2SvQw9sOjucEkTARRoWZqtMHsb1aXdLG70pOjJJiIy0ZWuDgpZdJk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1750641428756208.12093395621434; Sun, 22 Jun 2025 18:17:08 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1021977.1397691 (Exim 4.92) (envelope-from ) id 1uTVnd-00041k-1N; Mon, 23 Jun 2025 01:16:41 +0000 Received: by outflank-mailman (output) from mailman id 1021977.1397691; Mon, 23 Jun 2025 01:16:41 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uTVnc-00041d-To; Mon, 23 Jun 2025 01:16:40 +0000 Received: by outflank-mailman (input) for mailman id 1021977; Mon, 23 Jun 2025 01:16:39 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uTVna-00041X-Gt for xen-devel@lists.xenproject.org; Mon, 23 Jun 2025 01:16:39 +0000 Received: from mail-10628.protonmail.ch (mail-10628.protonmail.ch [79.135.106.28]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id b4a98339-4fcf-11f0-a30f-13f23c93f187; Mon, 23 Jun 2025 03:16:35 +0200 (CEST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: b4a98339-4fcf-11f0-a30f-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1750641394; x=1750900594; bh=PMAd4zFxcXv5vGZUSDMj0BvN3PyFw2OdCgQnVuQcNh0=; h=Date:To:From:Cc:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=mhtiPvKs4CuQXBO9Ueh+xug38LpA8Me19CNUKoB8nOHtLSHwJVlkeVCpKBsU3EtUX jXwVfKL1hQjnKaBkc8yjjEvQmrIfLtKh7zgUsrgbYsqUF25wdDOj2OT8p5p49PesWC 1A14oq42f1Egab+4G3qpM3taOzvY69/FLDWD2cP2rl4MG0lw2jm64PBgHEaK2fjBFM Bdc7SNaddOBEw0rf9oJgQCt178F7fYSvQX1uEeUU//s/YuGOi58JUhxuh+2sZKo13h 946SoGElXoIcfqWxPrLp+zAUeL1PGVlOAJZn4O/qk5YemJu4dcu7zi66wpDwmre96k opcbEM5aK1NYA== Date: Mon, 23 Jun 2025 01:16:28 +0000 To: xen-devel@lists.xenproject.org From: dmkhn@proton.me Cc: andrew.cooper3@citrix.com, anthony.perard@vates.tech, jbeulich@suse.com, julien@xen.org, michal.orzel@amd.com, roger.pau@citrix.com, sstabellini@kernel.org, dmukhin@ford.com Subject: [PATCH v1] xen/domain: fix memory leak in domain_create() Message-ID: <20250623011514.173367-1-dmukhin@ford.com> Feedback-ID: 123220910:user:proton X-Pm-Message-ID: afa7b6199ee8a1cf08082bdff2dc07f5930bfacf MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @proton.me) X-ZM-MESSAGEID: 1750641430124116600 Content-Type: text/plain; charset="utf-8" From: Denis Mukhin Fix potential memory leak in domain_create() in late hardware domain case. Fixes: b959f3b820f5 ("xen: introduce hardware domain create flag") Signed-off-by: Denis Mukhin Reviewed-by: Jan Beulich --- I think that no memory allocation is required before performing late hwdom checks (ID range and hwdom existance). Looks like sanitise_domain_config() could better fit for performing such configuration checks. Alternatively, hardware_domid range could be checked via custom parser instead of code in domain_create() and then hwdom existance can be moved before alloc_domain_struct(). Thoughts? --- xen/common/domain.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/xen/common/domain.c b/xen/common/domain.c index 2f6b0af50dd3..5ad1ac872798 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -825,7 +825,10 @@ struct domain *domain_create(domid_t domid, =20 /* late_hwdom is only allowed for dom0. */ if ( hardware_domain && hardware_domain->domain_id ) + { + free_domain_struct(d); return ERR_PTR(-EINVAL); + } =20 old_hwdom =3D hardware_domain; hardware_domain =3D d; --=20 2.34.1