[PATCH 1/8] KVM: gmem: Make kvm_gmem_bind return EBADF on wrong fd

From: isaku . yamahata
Date: Tue Aug 15 2023 - 13:20:09 EST


From: Isaku Yamahata <isaku.yamahata@xxxxxxxxx>

When kvm_gmem_bind() fails fget(), return EBADF instead of EINVAL because
EBADF is more appropriate.

Signed-off-by: Isaku Yamahata <isaku.yamahata@xxxxxxxxx>
---
virt/kvm/guest_mem.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/virt/kvm/guest_mem.c b/virt/kvm/guest_mem.c
index db644f7fa48b..c81d2bb9ae93 100644
--- a/virt/kvm/guest_mem.c
+++ b/virt/kvm/guest_mem.c
@@ -479,7 +479,7 @@ int kvm_gmem_bind(struct kvm *kvm, struct kvm_memory_slot *slot,

file = fget(fd);
if (!file)
- return -EINVAL;
+ return -EBADF;

if (file->f_op != &kvm_gmem_fops)
goto err;
--
2.25.1