File tree Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -2935,7 +2935,7 @@ static long kvm_vm_ioctl(struct file *filp,
2935
2935
case KVM_SET_GSI_ROUTING : {
2936
2936
struct kvm_irq_routing routing ;
2937
2937
struct kvm_irq_routing __user * urouting ;
2938
- struct kvm_irq_routing_entry * entries ;
2938
+ struct kvm_irq_routing_entry * entries = NULL ;
2939
2939
2940
2940
r = - EFAULT ;
2941
2941
if (copy_from_user (& routing , argp , sizeof (routing )))
@@ -2945,15 +2945,17 @@ static long kvm_vm_ioctl(struct file *filp,
2945
2945
goto out ;
2946
2946
if (routing .flags )
2947
2947
goto out ;
2948
- r = - ENOMEM ;
2949
- entries = vmalloc (routing .nr * sizeof (* entries ));
2950
- if (!entries )
2951
- goto out ;
2952
- r = - EFAULT ;
2953
- urouting = argp ;
2954
- if (copy_from_user (entries , urouting -> entries ,
2955
- routing .nr * sizeof (* entries )))
2956
- goto out_free_irq_routing ;
2948
+ if (routing .nr ) {
2949
+ r = - ENOMEM ;
2950
+ entries = vmalloc (routing .nr * sizeof (* entries ));
2951
+ if (!entries )
2952
+ goto out ;
2953
+ r = - EFAULT ;
2954
+ urouting = argp ;
2955
+ if (copy_from_user (entries , urouting -> entries ,
2956
+ routing .nr * sizeof (* entries )))
2957
+ goto out_free_irq_routing ;
2958
+ }
2957
2959
r = kvm_set_irq_routing (kvm , entries , routing .nr ,
2958
2960
routing .flags );
2959
2961
out_free_irq_routing :
You can’t perform that action at this time.
0 commit comments