Commit 8899a5fc authored by Colin Ian King's avatar Colin Ian King Committed by Paolo Bonzini

KVM: x86: Fix potential fput on a null source_kvm_file

The fget can potentially return null, so the fput on the error return
path can cause a null pointer dereference. Fix this by checking for
a null source_kvm_file before doing a fput.

Addresses-Coverity: ("Dereference null return")
Fixes: 54526d1f ("KVM: x86: Support KVM VMs sharing SEV context")
Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
Message-Id: <20210430170303.131924-1-colin.king@canonical.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 7f6231a3
......@@ -1764,7 +1764,8 @@ int svm_vm_copy_asid_from(struct kvm *kvm, unsigned int source_fd)
e_source_unlock:
mutex_unlock(&source_kvm->lock);
e_source_put:
fput(source_kvm_file);
if (source_kvm_file)
fput(source_kvm_file);
return ret;
}
......
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