]> www.infradead.org Git - users/jedix/linux-maple.git/commit
KVM: selftests: Fix mostly theoretical leak of VM's binary stats FD
authorSean Christopherson <seanjc@google.com>
Sat, 11 Jan 2025 00:50:41 +0000 (16:50 -0800)
committerSean Christopherson <seanjc@google.com>
Wed, 12 Feb 2025 17:02:42 +0000 (09:02 -0800)
commitfd546aba1967bb05ddb569272f56abb75f604bd7
tree013dbfc1a9a650a98c4e3077342f086b48b24357
parentdae7d81e8d5819bb47d63918c98539d9666a45d1
KVM: selftests: Fix mostly theoretical leak of VM's binary stats FD

When allocating and freeing a VM's cached binary stats info, check for a
NULL descriptor, not a '0' file descriptor, as '0' is a legal FD.  E.g. in
the unlikely scenario the kernel installs the stats FD at entry '0',
selftests would reallocate on the next __vm_get_stat() and/or fail to free
the stats in kvm_vm_free().

Fixes: 83f6e109f562 ("KVM: selftests: Cache binary stats metadata for duration of test")
Link: https://lore.kernel.org/r/20250111005049.1247555-2-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
tools/testing/selftests/kvm/lib/kvm_util.c