diff mbox series

KVM: Add missing fput() on error path

Message ID 64117a7f-ece5-42b1-a88a-3a1412f76dca@moroto.mountain (mailing list archive)
State New, archived
Headers show
Series KVM: Add missing fput() on error path | expand

Commit Message

Dan Carpenter Oct. 31, 2023, 8:58 a.m. UTC
Call fput() on this error path.

Fixes: fcbef1e5e5d2 ("KVM: Add KVM_CREATE_GUEST_MEMFD ioctl() for guest-specific backing memory")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 virt/kvm/guest_memfd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Sean Christopherson Oct. 31, 2023, 2:04 p.m. UTC | #1
On Tue, Oct 31, 2023, Dan Carpenter wrote:
> Call fput() on this error path.
> 
> Fixes: fcbef1e5e5d2 ("KVM: Add KVM_CREATE_GUEST_MEMFD ioctl() for guest-specific backing memory")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>  virt/kvm/guest_memfd.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/virt/kvm/guest_memfd.c b/virt/kvm/guest_memfd.c
> index 7f62abe3df9e..039f1bb70a0c 100644
> --- a/virt/kvm/guest_memfd.c
> +++ b/virt/kvm/guest_memfd.c
> @@ -473,7 +473,7 @@ int kvm_gmem_bind(struct kvm *kvm, struct kvm_memory_slot *slot,
>  	inode = file_inode(file);
>  
>  	if (offset < 0 || !PAGE_ALIGNED(offset))
> -		return -EINVAL;
> +		goto err;

Gah, I messed up when squashing a fix for v13.

Paolo, assuming you're grabbing all the fixups for v14, please apply this one too.
Paolo Bonzini Oct. 31, 2023, 2:04 p.m. UTC | #2
On 10/31/23 15:04, Sean Christopherson wrote:
>>   
>>   	if (offset < 0 || !PAGE_ALIGNED(offset))
>> -		return -EINVAL;
>> +		goto err;
> Gah, I messed up when squashing a fix for v13.
> 
> Paolo, assuming you're grabbing all the fixups for v14, please apply this one too.

Yes, it was already on my list. :)

Paolo
diff mbox series

Patch

diff --git a/virt/kvm/guest_memfd.c b/virt/kvm/guest_memfd.c
index 7f62abe3df9e..039f1bb70a0c 100644
--- a/virt/kvm/guest_memfd.c
+++ b/virt/kvm/guest_memfd.c
@@ -473,7 +473,7 @@  int kvm_gmem_bind(struct kvm *kvm, struct kvm_memory_slot *slot,
 	inode = file_inode(file);
 
 	if (offset < 0 || !PAGE_ALIGNED(offset))
-		return -EINVAL;
+		goto err;
 
 	if (offset + size > i_size_read(inode))
 		goto err;