Commit 18595411 authored by Guo Chao's avatar Guo Chao Committed by Marcelo Tosatti

KVM: do not kfree error pointer

We should avoid kfree()ing error pointer in kvm_vcpu_ioctl() and
kvm_arch_vcpu_ioctl().
Signed-off-by: default avatarGuo Chao <yan@linux.vnet.ibm.com>
Signed-off-by: default avatarMarcelo Tosatti <mtosatti@redhat.com>
parent f026399f
...@@ -2689,14 +2689,11 @@ long kvm_arch_vcpu_ioctl(struct file *filp, ...@@ -2689,14 +2689,11 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
break; break;
} }
case KVM_SET_LAPIC: { case KVM_SET_LAPIC: {
r = -EINVAL;
if (!vcpu->arch.apic) if (!vcpu->arch.apic)
goto out; goto out;
u.lapic = memdup_user(argp, sizeof(*u.lapic)); u.lapic = memdup_user(argp, sizeof(*u.lapic));
if (IS_ERR(u.lapic)) { if (IS_ERR(u.lapic))
r = PTR_ERR(u.lapic); return PTR_ERR(u.lapic);
goto out;
}
r = kvm_vcpu_ioctl_set_lapic(vcpu, u.lapic); r = kvm_vcpu_ioctl_set_lapic(vcpu, u.lapic);
if (r) if (r)
...@@ -2877,10 +2874,8 @@ long kvm_arch_vcpu_ioctl(struct file *filp, ...@@ -2877,10 +2874,8 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
} }
case KVM_SET_XSAVE: { case KVM_SET_XSAVE: {
u.xsave = memdup_user(argp, sizeof(*u.xsave)); u.xsave = memdup_user(argp, sizeof(*u.xsave));
if (IS_ERR(u.xsave)) { if (IS_ERR(u.xsave))
r = PTR_ERR(u.xsave); return PTR_ERR(u.xsave);
goto out;
}
r = kvm_vcpu_ioctl_x86_set_xsave(vcpu, u.xsave); r = kvm_vcpu_ioctl_x86_set_xsave(vcpu, u.xsave);
break; break;
...@@ -2902,10 +2897,8 @@ long kvm_arch_vcpu_ioctl(struct file *filp, ...@@ -2902,10 +2897,8 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
} }
case KVM_SET_XCRS: { case KVM_SET_XCRS: {
u.xcrs = memdup_user(argp, sizeof(*u.xcrs)); u.xcrs = memdup_user(argp, sizeof(*u.xcrs));
if (IS_ERR(u.xcrs)) { if (IS_ERR(u.xcrs))
r = PTR_ERR(u.xcrs); return PTR_ERR(u.xcrs);
goto out;
}
r = kvm_vcpu_ioctl_x86_set_xcrs(vcpu, u.xcrs); r = kvm_vcpu_ioctl_x86_set_xcrs(vcpu, u.xcrs);
break; break;
......
...@@ -1954,6 +1954,7 @@ static long kvm_vcpu_ioctl(struct file *filp, ...@@ -1954,6 +1954,7 @@ static long kvm_vcpu_ioctl(struct file *filp,
kvm_sregs = memdup_user(argp, sizeof(*kvm_sregs)); kvm_sregs = memdup_user(argp, sizeof(*kvm_sregs));
if (IS_ERR(kvm_sregs)) { if (IS_ERR(kvm_sregs)) {
r = PTR_ERR(kvm_sregs); r = PTR_ERR(kvm_sregs);
kvm_sregs = NULL;
goto out; goto out;
} }
r = kvm_arch_vcpu_ioctl_set_sregs(vcpu, kvm_sregs); r = kvm_arch_vcpu_ioctl_set_sregs(vcpu, kvm_sregs);
...@@ -2054,6 +2055,7 @@ static long kvm_vcpu_ioctl(struct file *filp, ...@@ -2054,6 +2055,7 @@ static long kvm_vcpu_ioctl(struct file *filp,
fpu = memdup_user(argp, sizeof(*fpu)); fpu = memdup_user(argp, sizeof(*fpu));
if (IS_ERR(fpu)) { if (IS_ERR(fpu)) {
r = PTR_ERR(fpu); r = PTR_ERR(fpu);
fpu = NULL;
goto out; goto out;
} }
r = kvm_arch_vcpu_ioctl_set_fpu(vcpu, fpu); r = kvm_arch_vcpu_ioctl_set_fpu(vcpu, fpu);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment