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,
29352935 case KVM_SET_GSI_ROUTING : {
29362936 struct kvm_irq_routing routing ;
29372937 struct kvm_irq_routing __user * urouting ;
2938- struct kvm_irq_routing_entry * entries ;
2938+ struct kvm_irq_routing_entry * entries = NULL ;
29392939
29402940 r = - EFAULT ;
29412941 if (copy_from_user (& routing , argp , sizeof (routing )))
@@ -2945,15 +2945,17 @@ static long kvm_vm_ioctl(struct file *filp,
29452945 goto out ;
29462946 if (routing .flags )
29472947 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+ }
29572959 r = kvm_set_irq_routing (kvm , entries , routing .nr ,
29582960 routing .flags );
29592961out_free_irq_routing :
You can’t perform that action at this time.
0 commit comments