diff options
author | Carsten Otte <cotte@de.ibm.com> | 2011-10-18 06:27:12 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2011-10-30 06:20:55 -0400 |
commit | 4d47555a80495657161a7e71ec3014ff2021e450 (patch) | |
tree | f5e12258ee93dc20c230e7dc60620c6d0194142e /arch/s390/kvm/kvm-s390.c | |
parent | a3e06bbe8445f57eb949e6474c5a9b30f24d2057 (diff) |
KVM: s390: check cpu_id prior to using it
We use the cpu id provided by userspace as array index here. Thus we
clearly need to check it first. Ooops.
CC: <stable@vger.kernel.org>
Signed-off-by: Carsten Otte <cotte@de.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'arch/s390/kvm/kvm-s390.c')
-rw-r--r-- | arch/s390/kvm/kvm-s390.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index dc2b580e27b..0cba935d128 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c | |||
@@ -312,11 +312,17 @@ int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu) | |||
312 | struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, | 312 | struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, |
313 | unsigned int id) | 313 | unsigned int id) |
314 | { | 314 | { |
315 | struct kvm_vcpu *vcpu = kzalloc(sizeof(struct kvm_vcpu), GFP_KERNEL); | 315 | struct kvm_vcpu *vcpu; |
316 | int rc = -ENOMEM; | 316 | int rc = -EINVAL; |
317 | |||
318 | if (id >= KVM_MAX_VCPUS) | ||
319 | goto out; | ||
320 | |||
321 | rc = -ENOMEM; | ||
317 | 322 | ||
323 | vcpu = kzalloc(sizeof(struct kvm_vcpu), GFP_KERNEL); | ||
318 | if (!vcpu) | 324 | if (!vcpu) |
319 | goto out_nomem; | 325 | goto out; |
320 | 326 | ||
321 | vcpu->arch.sie_block = (struct kvm_s390_sie_block *) | 327 | vcpu->arch.sie_block = (struct kvm_s390_sie_block *) |
322 | get_zeroed_page(GFP_KERNEL); | 328 | get_zeroed_page(GFP_KERNEL); |
@@ -352,7 +358,7 @@ out_free_sie_block: | |||
352 | free_page((unsigned long)(vcpu->arch.sie_block)); | 358 | free_page((unsigned long)(vcpu->arch.sie_block)); |
353 | out_free_cpu: | 359 | out_free_cpu: |
354 | kfree(vcpu); | 360 | kfree(vcpu); |
355 | out_nomem: | 361 | out: |
356 | return ERR_PTR(rc); | 362 | return ERR_PTR(rc); |
357 | } | 363 | } |
358 | 364 | ||