Re: [PATCH v3] KVM: x86: fix for missing initialization of return status variable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Dec 06, 2021 at 05:02:01PM +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
> > ioctl, we should trigger KVM_BUG_ON() and return with EIO to silent
> > coverity warning.
> > 
> > Addresses-Coverity: 1494124 ("Uninitialized scalar variable")
> > Signed-off-by: Ameer Hamza <amhamza.mgc@xxxxxxxxx>
> > ---
> > Changes in v3:
> > Added KVM_BUG_ON() as default case and returned -EIO
> > ---
> >  arch/x86/kvm/x86.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> > index e0aa4dd53c7f..b37068f847ff 100644
> > --- a/arch/x86/kvm/x86.c
> > +++ b/arch/x86/kvm/x86.c
> > @@ -5019,6 +5019,9 @@ 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:
> > +		KVM_BUG_ON(1, vcpu->kvm);
> > +		r = -EIO;
> 
> At least have a
> 
> 		break;
> 
> if we're going to be pedantic about things.
I just started as a contributer in this community and trying
to fix issues found by static analyzer tools. If you think that's
not necessary, its totally fine :)

> >  	}
> >  
> >  	return r;
> > -- 
> > 2.25.1
> > 



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux