diff options
| author | Xin Li (Intel) <[email protected]> | 2025-05-17 16:57:12 +0000 |
|---|---|---|
| committer | Ingo Molnar <[email protected]> | 2025-05-21 06:44:31 +0000 |
| commit | e95534e107d2e9e136aa4d7cbededb3827e80074 (patch) | |
| tree | 3b6df10f47e9951ea13cda291f0dcf079694d4ea | |
| parent | x86/msr: Remove a superfluous inclusion of <asm/asm.h> (diff) | |
| download | kernel-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.c | 4 |
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); } |
