aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXin Li (Intel) <[email protected]>2025-05-17 16:57:12 +0000
committerIngo Molnar <[email protected]>2025-05-21 06:44:31 +0000
commite95534e107d2e9e136aa4d7cbededb3827e80074 (patch)
tree3b6df10f47e9951ea13cda291f0dcf079694d4ea
parentx86/msr: Remove a superfluous inclusion of <asm/asm.h> (diff)
downloadkernel-e95534e107d2e9e136aa4d7cbededb3827e80074.tar.gz
kernel-e95534e107d2e9e136aa4d7cbededb3827e80074.zip
x86/xen/msr: Fix uninitialized variable 'err'
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(). Do the same in xen_read_msr(), even err is not used after being passed to xen_do_read_msr(). Closes: https://lore.kernel.org/xen-devel/[email protected]/ Reported-by: Dan Carpenter <[email protected]> Signed-off-by: Xin Li (Intel) <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Reviewed-by: Juergen Gross <[email protected]> Cc: H. Peter Anvin <[email protected]> Link: https://lore.kernel.org/r/[email protected]
-rw-r--r--arch/x86/xen/enlighten_pv.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c
index 7f9ded1bc707..26bbaf4b7330 100644
--- a/arch/x86/xen/enlighten_pv.c
+++ b/arch/x86/xen/enlighten_pv.c
@@ -1162,7 +1162,7 @@ static void xen_do_write_msr(u32 msr, u64 val, int *err)
static int xen_read_msr_safe(u32 msr, u64 *val)
{
- int err;
+ int err = 0;
*val = xen_do_read_msr(msr, &err);
return err;
@@ -1179,7 +1179,7 @@ static int xen_write_msr_safe(u32 msr, u64 val)
static u64 xen_read_msr(u32 msr)
{
- int err;
+ int err = 0;
return xen_do_read_msr(msr, xen_msr_safe ? &err : NULL);
}