Skip to content

Commit

Permalink
KVM: s390: check cpu_id prior to using it
Browse files Browse the repository at this point in the history
We use the cpu id provided by userspace as array index here. Thus we
clearly need to check it first. Ooops.

CC: <[email protected]>
Signed-off-by: Carsten Otte <[email protected]>
Signed-off-by: Christian Borntraeger <[email protected]>
Signed-off-by: Marcelo Tosatti <[email protected]>
  • Loading branch information
Carsten Otte authored and avikivity committed Oct 30, 2011
1 parent a3e06bb commit 4d47555
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions arch/s390/kvm/kvm-s390.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,11 +312,17 @@ int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu)
struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm,
unsigned int id)
{
struct kvm_vcpu *vcpu = kzalloc(sizeof(struct kvm_vcpu), GFP_KERNEL);
int rc = -ENOMEM;
struct kvm_vcpu *vcpu;
int rc = -EINVAL;

if (id >= KVM_MAX_VCPUS)
goto out;

rc = -ENOMEM;

vcpu = kzalloc(sizeof(struct kvm_vcpu), GFP_KERNEL);
if (!vcpu)
goto out_nomem;
goto out;

vcpu->arch.sie_block = (struct kvm_s390_sie_block *)
get_zeroed_page(GFP_KERNEL);
Expand Down Expand Up @@ -352,7 +358,7 @@ struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm,
free_page((unsigned long)(vcpu->arch.sie_block));
out_free_cpu:
kfree(vcpu);
out_nomem:
out:
return ERR_PTR(rc);
}

Expand Down

0 comments on commit 4d47555

Please sign in to comment.