File tree Expand file tree Collapse file tree 2 files changed +15
-21
lines changed Expand file tree Collapse file tree 2 files changed +15
-21
lines changed Original file line number Diff line number Diff line change @@ -181,17 +181,14 @@ int kvm_vcpu_ioctl_set_cpuid(struct kvm_vcpu *vcpu,
181
181
r = - E2BIG ;
182
182
if (cpuid -> nent > KVM_MAX_CPUID_ENTRIES )
183
183
goto out ;
184
- r = - ENOMEM ;
185
184
if (cpuid -> nent ) {
186
- cpuid_entries =
187
- vmalloc (array_size (sizeof (struct kvm_cpuid_entry ),
188
- cpuid -> nent ));
189
- if (!cpuid_entries )
190
- goto out ;
191
- r = - EFAULT ;
192
- if (copy_from_user (cpuid_entries , entries ,
193
- cpuid -> nent * sizeof (struct kvm_cpuid_entry )))
185
+ cpuid_entries = vmemdup_user (entries ,
186
+ array_size (sizeof (struct kvm_cpuid_entry ),
187
+ cpuid -> nent ));
188
+ if (IS_ERR (cpuid_entries )) {
189
+ r = PTR_ERR (cpuid_entries );
194
190
goto out ;
191
+ }
195
192
}
196
193
for (i = 0 ; i < cpuid -> nent ; i ++ ) {
197
194
vcpu -> arch .cpuid_entries [i ].function = cpuid_entries [i ].function ;
@@ -211,8 +208,8 @@ int kvm_vcpu_ioctl_set_cpuid(struct kvm_vcpu *vcpu,
211
208
kvm_x86_ops .cpuid_update (vcpu );
212
209
r = kvm_update_cpuid (vcpu );
213
210
211
+ kvfree (cpuid_entries );
214
212
out :
215
- vfree (cpuid_entries );
216
213
return r ;
217
214
}
218
215
Original file line number Diff line number Diff line change @@ -3746,21 +3746,18 @@ static long kvm_vm_ioctl(struct file *filp,
3746
3746
if (routing .flags )
3747
3747
goto out ;
3748
3748
if (routing .nr ) {
3749
- r = - ENOMEM ;
3750
- entries = vmalloc (array_size (sizeof (* entries ),
3751
- routing .nr ));
3752
- if (!entries )
3753
- goto out ;
3754
- r = - EFAULT ;
3755
3749
urouting = argp ;
3756
- if (copy_from_user (entries , urouting -> entries ,
3757
- routing .nr * sizeof (* entries )))
3758
- goto out_free_irq_routing ;
3750
+ entries = vmemdup_user (urouting -> entries ,
3751
+ array_size (sizeof (* entries ),
3752
+ routing .nr ));
3753
+ if (IS_ERR (entries )) {
3754
+ r = PTR_ERR (entries );
3755
+ goto out ;
3756
+ }
3759
3757
}
3760
3758
r = kvm_set_irq_routing (kvm , entries , routing .nr ,
3761
3759
routing .flags );
3762
- out_free_irq_routing :
3763
- vfree (entries );
3760
+ kvfree (entries );
3764
3761
break ;
3765
3762
}
3766
3763
#endif /* CONFIG_HAVE_KVM_IRQ_ROUTING */
You can’t perform that action at this time.
0 commit comments