Coverity: emulator_leave_smm(): Error handling issues

From: coverity-bot
Date: Thu Dec 01 2022 - 11:25:59 EST


Hello!

This is an experimental semi-automated report about issues detected by
Coverity from a scan of next-20221201 as part of the linux-next scan project:
https://scan.coverity.com/projects/linux-next-weekly-scan

You're getting this email because you were associated with the identified
lines of code (noted below) that were touched by commits:

Wed Nov 9 12:31:18 2022 -0500
1d0da94cdafe ("KVM: x86: do not go through ctxt->ops when emulating rsm")

Coverity reported the following:

*** CID 1527763: Error handling issues (CHECKED_RETURN)
arch/x86/kvm/smm.c:631 in emulator_leave_smm()
625 cr4 = kvm_read_cr4(vcpu);
626 if (cr4 & X86_CR4_PAE)
627 kvm_set_cr4(vcpu, cr4 & ~X86_CR4_PAE);
628
629 /* And finally go back to 32-bit mode. */
630 efer = 0;
vvv CID 1527763: Error handling issues (CHECKED_RETURN)
vvv Calling "kvm_set_msr" without checking return value (as is done elsewhere 5 out of 6 times).
631 kvm_set_msr(vcpu, MSR_EFER, efer);
632 }
633 #endif
634
635 /*
636 * Give leave_smm() a chance to make ISA-specific changes to the vCPU

If this is a false positive, please let us know so we can mark it as
such, or teach the Coverity rules to be smarter. If not, please make
sure fixes get into linux-next. :) For patches fixing this, please
include these lines (but double-check the "Fixes" first):

Reported-by: coverity-bot <keescook+coverity-bot@xxxxxxxxxxxx>
Addresses-Coverity-ID: 1527763 ("Error handling issues")
Fixes: 1d0da94cdafe ("KVM: x86: do not go through ctxt->ops when emulating rsm")

Thanks for your attention!

--
Coverity-bot