From nobody Wed Dec 17 10:46:22 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=none dis=none) header.from=zytor.com ARC-Seal: i=1; a=rsa-sha256; t=1747039617; cv=none; d=zohomail.com; s=zohoarc; b=jeE2JtizrLHDzXkqlCPE0J1Hzo0rxvMJxOmwGa7w+hEOif5ZsnmgNZdr9kBd5hk5AonYRQG1yGB9aY/IuR9kp0v5453bwCjYbBEVLYElyQjeUvGX+XS94jRWlxFM0ciIntTx4Lrfzmfbu6q7ydaLRkAqJg3PjCzNyOq6LkH8S2M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747039617; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=r60JlXTos4KUiP7BNV4Mubm1J2LcZX1eO8iTOKbeekU=; b=A9fGUrswWD64ad+0bJ/s638AZn1+8V4iv86w4hvCVGycFm4WydULMoTwJJ9SHxym/ImzisOCOf0ZCy5gEAtKLSnuvQq2aphWsF1/SdQ/j75sLaMorFsKeA/p+i6O8LFVTx/cXHEKVBSJHyjkqqD0O8Ujw0UFTUBuiMTjprunbsM= 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=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1747039617881182.59005863599702; Mon, 12 May 2025 01:46:57 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.980965.1367377 (Exim 4.92) (envelope-from ) id 1uEOo9-0004GM-Ay; Mon, 12 May 2025 08:46:45 +0000 Received: by outflank-mailman (output) from mailman id 980965.1367377; Mon, 12 May 2025 08:46:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uEOo9-0004GF-6x; Mon, 12 May 2025 08:46:45 +0000 Received: by outflank-mailman (input) for mailman id 980965; Mon, 12 May 2025 08:46:43 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uEOo7-0003Qj-Fz for xen-devel@lists.xenproject.org; Mon, 12 May 2025 08:46:43 +0000 Received: from mail.zytor.com (terminus.zytor.com [2607:7c80:54:3::136]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 970f45be-2f0d-11f0-9ffb-bf95429c2676; Mon, 12 May 2025 10:46:28 +0200 (CEST) Received: from terminus.zytor.com (terminus.zytor.com [IPv6:2607:7c80:54:3:0:0:0:136]) (authenticated bits=0) by mail.zytor.com (8.18.1/8.17.1) with ESMTPSA id 54C8jqc61586901 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Mon, 12 May 2025 01:46:01 -0700 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: 970f45be-2f0d-11f0-9ffb-bf95429c2676 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 54C8jqc61586901 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2025042001; t=1747039562; bh=r60JlXTos4KUiP7BNV4Mubm1J2LcZX1eO8iTOKbeekU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bmWYvnwxTU0pVJW4u5KvyhR8cTc1ILbP2oLLV6/74QxSidvlgisrmNIxqhqDAWxKZ TfRpxdQFxnaY6yhrR7m4LAqjzS1vvDMK3xmikiuu/o0qUX54thQc2j1Gjq2HQ4VNwr rQKjxAF2qcQOahokDI2/tvLM1hf8YVHZ+abqqiF51/1wliz8hXeqPJdAFOMveLB42B DSKDUbp1sv3q/sTl5Z8xcEzVErSlNqGYT1F1PLCScIypX4jxPqjgttEGM9q3tH7Gdv i3o5hUvLakD4MvXrM6mRnnF2KzfqtpiDMAQ8pAj28Y0O3oXTU0l3ue3PDx/tGmMrY1 Snn6b8NY550AQ== From: "Xin Li (Intel)" To: linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org Cc: tglx@linutronix.de, mingo@kernel.org, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, peterz@infradead.org, jgross@suse.com, boris.ostrovsky@oracle.com, rafael@kernel.org, lenb@kernel.org Subject: [PATCH v1 2/3] x86/xen/msr: Fix uninitialized symbol 'err' Date: Mon, 12 May 2025 01:45:51 -0700 Message-ID: <20250512084552.1586883-3-xin@zytor.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250512084552.1586883-1-xin@zytor.com> References: <20250512084552.1586883-1-xin@zytor.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @zytor.com) X-ZM-MESSAGEID: 1747039619155019000 Content-Type: text/plain; charset="utf-8" xen_read_msr_safe() currently passes an uninitialized argument err to xen_do_read_msr(). But as xen_do_read_msr() may not set the argument, xen_read_msr_safe() could return err with an unpredictable value. To ensure correctness, initialize err to 0 (representing success) in xen_read_msr_safe(). Because xen_read_msr_safe() is essentially a wrapper of xen_do_read_msr(), the latter should be responsible for initializing the value of *err to 0. Thus initialize *err to 0 in xen_do_read_msr(). Fixes: 502ad6e5a619 ("x86/msr: Change the function type of native_read_msr_= safe()") Reported-by: Dan Carpenter Closes: https://lore.kernel.org/xen-devel/aBxNI_Q0-MhtBSZG@stanley.mountain/ Signed-off-by: Xin Li (Intel) --- arch/x86/xen/enlighten_pv.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c index 3be38350f044..01f1d441347e 100644 --- a/arch/x86/xen/enlighten_pv.c +++ b/arch/x86/xen/enlighten_pv.c @@ -1091,6 +1091,9 @@ static u64 xen_do_read_msr(u32 msr, int *err) { u64 val =3D 0; /* Avoid uninitialized value for safe variant. */ =20 + if (err) + *err =3D 0; + if (pmu_msr_chk_emulated(msr, &val, true)) return val; =20 @@ -1162,7 +1165,7 @@ static void xen_do_write_msr(u32 msr, u64 val, int *e= rr) =20 static int xen_read_msr_safe(u32 msr, u64 *val) { - int err; + int err =3D 0; =20 *val =3D xen_do_read_msr(msr, &err); return err; --=20 2.49.0