diff options
author | Colin Ian King <colin.king@canonical.com> | 2021-04-30 19:03:03 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2021-05-03 17:25:40 +0200 |
commit | 8899a5fc7da516460f841189a28aac0b52b554fd (patch) | |
tree | f216b9cbf7ddc89a3bdccbf6fe14006d70ee34ad /arch | |
parent | KVM: x86/mmu: Fix kdoc of __handle_changed_spte (diff) | |
download | linux-8899a5fc7da516460f841189a28aac0b52b554fd.tar.xz linux-8899a5fc7da516460f841189a28aac0b52b554fd.zip |
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: 54526d1fd593 ("KVM: x86: Support KVM VMs sharing SEV context")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Message-Id: <20210430170303.131924-1-colin.king@canonical.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/kvm/svm/sev.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index 1356ee095cd5..8b11c711a0e4 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -1764,7 +1764,8 @@ e_mirror_unlock: 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; } |