RE: [PATCH V5 2/8] x86/hyperv: Set Virtual Trust Level in VMBus init message

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

 



> From: Tianyu Lan <ltykernel@xxxxxxxxx>
> Sent: Thursday, August 10, 2023 9:04 AM
>  [...]
> diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
> @@ -378,6 +378,41 @@ static void __init hv_get_partition_id(void)
>  	local_irq_restore(flags);
>  }
> 
> +static u8 __init get_vtl(void)
> +{
> +	u64 control = HV_HYPERCALL_REP_COMP_1 |
> HVCALL_GET_VP_REGISTERS;
> +	struct hv_get_vp_registers_input *input;
> +	struct hv_get_vp_registers_output *output;
> +	unsigned long flags;
> +	u64 ret;

This should be
	u64 ret = 0;

> +	local_irq_save(flags);
> +	input = *this_cpu_ptr(hyperv_pcpu_input_arg);
> +	output = (struct hv_get_vp_registers_output *)input;
> +	if (!input) {
> +		local_irq_restore(flags);
> +		goto done;

Here the uninitialized 'ret' is returned. 

If we move the "done:" label one line earlier, we won't need the 
the above " local_irq_restore(flags);"
Maybe we should add a WARN_ON_ONCE(1) before "goto done"?

> +	}
> +
> +	memset(input, 0, struct_size(input, element, 1));
> +	input->header.partitionid = HV_PARTITION_ID_SELF;
> +	input->header.vpindex = HV_VP_INDEX_SELF;
> +	input->header.inputvtl = 0;
> +	input->element[0].name0 = HV_X64_REGISTER_VSM_VP_STATUS;
> +
> +	ret = hv_do_hypercall(control, input, output);
> +	if (hv_result_success(ret)) {
> +		ret = output->as64.low & HV_X64_VTL_MASK;
> +	} else {
> +		pr_err("Failed to get VTL and set VTL to zero by default.\n");
> +		ret = 0;

If we have "u64 ret = 0;", we won't need the "ret = 0;" here, and we
won't need the curly braces.

> +	}
> +
> +	local_irq_restore(flags);
> +done:
> +	return ret;
> +}

After the above minor issues are fixed, feel free to add
Reviewed-by: Dexuan Cui <decui@xxxxxxxxxxxxx>




[Index of Archives]     [Linux Kernel]     [Kernel Newbies]     [x86 Platform Driver]     [Netdev]     [Linux Wireless]     [Netfilter]     [Bugtraq]     [Linux Filesystems]     [Yosemite Discussion]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]

  Powered by Linux