lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <diqza51zhc4m.fsf@google.com>
Date: Thu, 09 Oct 2025 16:46:33 -0700
From: Ackerley Tng <ackerleytng@...gle.com>
To: Sean Christopherson <seanjc@...gle.com>
Cc: pbonzini@...hat.com, kvm@...r.kernel.org, linux-kernel@...r.kernel.org, 
	seanjc@...gle.com
Subject: Re: [PATCH] KVM: guest_memfd: Drop a superfluous local var in kvm_gmem_fault_user_mapping()

Sean Christopherson <seanjc@...gle.com> writes:

> Drop the local "int err" that's buried in the middle guest_memfd's user
> fault handler to avoid the potential for variable shadowing, e.g. if an
> "err" variable were also declared at function scope.
>

Is the takeaway here that the variable name "err", if used, should be
defined at function scope?

IOW, would this code have been okay if any other variable name were
used, like if err_folio were used instead of err?

> No functional change intended.
>
> Signed-off-by: Sean Christopherson <seanjc@...gle.com>

Reviewed-by: Ackerley Tng <ackerleytng@...gle.com>

> ---
>  virt/kvm/guest_memfd.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/virt/kvm/guest_memfd.c b/virt/kvm/guest_memfd.c
> index 94bafd6c558c..abbec01d7a3a 100644
> --- a/virt/kvm/guest_memfd.c
> +++ b/virt/kvm/guest_memfd.c
> @@ -330,12 +330,10 @@ static vm_fault_t kvm_gmem_fault_user_mapping(struct vm_fault *vmf)
>  
>  	folio = kvm_gmem_get_folio(inode, vmf->pgoff);
>  	if (IS_ERR(folio)) {
> -		int err = PTR_ERR(folio);
> -
> -		if (err == -EAGAIN)
> +		if (PTR_ERR(folio) == -EAGAIN)
>  			return VM_FAULT_RETRY;
>  
> -		return vmf_error(err);
> +		return vmf_error(PTR_ERR(folio));
>  	}
>  
>  	if (WARN_ON_ONCE(folio_test_large(folio))) {
>
> base-commit: 6b36119b94d0b2bb8cea9d512017efafd461d6ac

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ