KVM: fix spectrev1 gadgets
These were found with smatch, and then generalized when applicable. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
@@ -2977,12 +2977,14 @@ static int kvm_ioctl_create_device(struct kvm *kvm,
|
||||
struct kvm_device_ops *ops = NULL;
|
||||
struct kvm_device *dev;
|
||||
bool test = cd->flags & KVM_CREATE_DEVICE_TEST;
|
||||
int type;
|
||||
int ret;
|
||||
|
||||
if (cd->type >= ARRAY_SIZE(kvm_device_ops_table))
|
||||
return -ENODEV;
|
||||
|
||||
ops = kvm_device_ops_table[cd->type];
|
||||
type = array_index_nospec(cd->type, ARRAY_SIZE(kvm_device_ops_table));
|
||||
ops = kvm_device_ops_table[type];
|
||||
if (ops == NULL)
|
||||
return -ENODEV;
|
||||
|
||||
@@ -2997,7 +2999,7 @@ static int kvm_ioctl_create_device(struct kvm *kvm,
|
||||
dev->kvm = kvm;
|
||||
|
||||
mutex_lock(&kvm->lock);
|
||||
ret = ops->create(dev, cd->type);
|
||||
ret = ops->create(dev, type);
|
||||
if (ret < 0) {
|
||||
mutex_unlock(&kvm->lock);
|
||||
kfree(dev);
|
||||
|
||||
Reference in New Issue
Block a user