Message ID | 20211206102403.10797-1-amhamza.mgc@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v2] KVM: x86: fix for missing initialization of return status variable | expand |
On Mon, Dec 06, 2021, Ameer Hamza wrote: > If undefined ioctl number is passed to the kvm_vcpu_ioctl_device_attr > function, it should return with error status. No, if anything KVM should do KVM_BUG_ON() and return -EIO, because @ioctl is completely KVM controlled. But I'd personally prefer we leave it as is, there's one call site that very clearly invokes the helper with only the three ioctls. It's not a strong preference though.
On Mon, Dec 06, 2021 at 03:37:43PM +0000, Sean Christopherson wrote: > On Mon, Dec 06, 2021, Ameer Hamza wrote: > > If undefined ioctl number is passed to the kvm_vcpu_ioctl_device_attr > > function, it should return with error status. > > No, if anything KVM should do KVM_BUG_ON() and return -EIO, because @ioctl is > completely KVM controlled. But I'd personally prefer we leave it as is, there's > one call site that very clearly invokes the helper with only the three ioctls. > It's not a strong preference though. Thank you for your response. I agree with you, but I think in my opinion, it would be nice to resolve coverity warning. Let me update the patch according to your suggestions anyway. Thanks, Hamza.
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index e0aa4dd53c7f..e6e00f997b1f 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -5019,6 +5019,8 @@ static int kvm_vcpu_ioctl_device_attr(struct kvm_vcpu *vcpu, case KVM_SET_DEVICE_ATTR: r = kvm_arch_tsc_set_attr(vcpu, &attr); break; + default: + r = -EINVAL; } return r;
If undefined ioctl number is passed to the kvm_vcpu_ioctl_device_attr function, it should return with error status. Addresses-Coverity: 1494124 ("Uninitialized scalar variable") Signed-off-by: Ameer Hamza <amhamza.mgc@gmail.com> --- Added default case to return EINV for undefined ioctl number --- arch/x86/kvm/x86.c | 2 ++ 1 file changed, 2 insertions(+)