KVM: apic: avoid calculating pending eoi from an uninitialized val
Quoted 6 lines · Sean Christopherson
Quoted 2 lines · Vitaly Kuznetsov
linmiaohe <[email protected]> writes:
Rather than initialize @val, I'd prefer to explicitly handle the error, similar to
pv_eoi_clr_pending()andpv_eoi_set_pending(), e.g.
Quoted 8 lines
u8 val;
if (pv_eoi_get_user(vcpu, &val) < 0) {
printk(KERN_WARNING "Can't read EOI MSR value: 0x%llx\n",
(unsigned long long)vcpu->arch.pv_eoi.msr_val);
return false;
}
return val & 0x1;Looks good. Handle the error explicitly can help remind us @val is unusable. Will do. Thanks.
Quoted 10 lines
Quoted 7 lines
Review
Quoted 3 lines
(quoted diff) +0
-0if (pv_eoi_get_user(vcpu, &val) < 0) printk(KERN_WARNING "Can't read EOI MSR value: 0x%llx\n", (unsigned long long)vcpu->arch.pv_eoi.msr_val);Reviewed-by Vitaly Kuznetsov <[email protected]>But why compilers don't complain?
Clang might?