mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
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:
parent
be43c440eb
commit
1d487e9bf8
4 changed files with 16 additions and 9 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue