aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390
diff options
context:
space:
mode:
authorCarsten Otte <cotte@de.ibm.com>2011-10-18 06:27:12 -0400
committerHerton Ronaldo Krzesinski <herton.krzesinski@canonical.com>2011-11-21 12:55:01 -0500
commitef373fdcbe66c1846cae65d5a80da96e20290e10 (patch)
treef2dfc8bb35816b431ce27beea3178a3e9c7d4e05 /arch/s390
parent9245851bb9033b0663bf9c62bfbf4372b205362c (diff)
KVM: s390: check cpu_id prior to using it
BugLink: http://bugs.launchpad.net/bugs/890952 commit 4d47555a80495657161a7e71ec3014ff2021e450 upstream. We use the cpu id provided by userspace as array index here. Thus we clearly need to check it first. Ooops. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
Diffstat (limited to 'arch/s390')
-rw-r--r--arch/s390/kvm/kvm-s390.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 67345ae7ce8..2ada634fc7c 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -301,11 +301,17 @@ int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu)
301struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, 301struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm,
302 unsigned int id) 302 unsigned int id)
303{ 303{
304 struct kvm_vcpu *vcpu = kzalloc(sizeof(struct kvm_vcpu), GFP_KERNEL); 304 struct kvm_vcpu *vcpu;
305 int rc = -ENOMEM; 305 int rc = -EINVAL;
306
307 if (id >= KVM_MAX_VCPUS)
308 goto out;
309
310 rc = -ENOMEM;
306 311
312 vcpu = kzalloc(sizeof(struct kvm_vcpu), GFP_KERNEL);
307 if (!vcpu) 313 if (!vcpu)
308 goto out_nomem; 314 goto out;
309 315
310 vcpu->arch.sie_block = (struct kvm_s390_sie_block *) 316 vcpu->arch.sie_block = (struct kvm_s390_sie_block *)
311 get_zeroed_page(GFP_KERNEL); 317 get_zeroed_page(GFP_KERNEL);
@@ -341,7 +347,7 @@ out_free_sie_block:
341 free_page((unsigned long)(vcpu->arch.sie_block)); 347 free_page((unsigned long)(vcpu->arch.sie_block));
342out_free_cpu: 348out_free_cpu:
343 kfree(vcpu); 349 kfree(vcpu);
344out_nomem: 350out:
345 return ERR_PTR(rc); 351 return ERR_PTR(rc);
346} 352}
347 353