Re: [PATCH] KVM: s390: Pass initialized arg even if unused

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Aug 24, 2022 at 05:30:11PM +0200, Janis Schoetterl-Glausch wrote:
> This silences smatch warnings reported by kbuild bot:
> arch/s390/kvm/gaccess.c:859 guest_range_to_gpas() error: uninitialized symbol 'prot'.
> arch/s390/kvm/gaccess.c:1064 access_guest_with_key() error: uninitialized symbol 'prot'.
> 
> This is because it cannot tell that the value is not used in this case.
> The trans_exc* only examine prot if code is PGM_PROTECTION.
> Pass a dummy value for other codes.
> 
> Reported-by: kernel test robot <lkp@xxxxxxxxx>
> Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> Signed-off-by: Janis Schoetterl-Glausch <scgl@xxxxxxxxxxxxx>
> ---
>  arch/s390/kvm/gaccess.c | 15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)
...
> @@ -503,6 +505,7 @@ static int trans_exc_ending(struct kvm_vcpu *vcpu, int code, unsigned long gva,
>  
>  	switch (code) {
>  	case PGM_PROTECTION:
> +		WARN(unlikely(prot == PROT_NONE), "Invalid prot argument");

The WARN macro comes with unlikely, please get rid of unlikely here. Also:

> +		case PROT_NONE:
> +			/* We should never get here, acts like termination */

Why not put it here? And make it WARN_ON_ONCE() in addition?

>  			gpa = kvm_s390_real_to_abs(vcpu, ga);
> -			if (kvm_is_error_gpa(vcpu->kvm, gpa))
> +			if (kvm_is_error_gpa(vcpu->kvm, gpa)) {
>  				rc = PGM_ADDRESSING;
> +				prot = PROT_NONE;
> +			}
...
> +		if (rc == PGM_PROTECTION)
> +			prot = PROT_TYPE_KEYC;
> +		else
> +			prot = PROT_NONE;

For both cases I would suggest to preinitialize prot with PROT_NONE in
order to keep the code smaller - but not my call.



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Kernel Development]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Info]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Linux Media]     [Device Mapper]

  Powered by Linux