Re: [PATCH next] Drivers: hv: mshv: Fix uninitialize variable in mshv_ioctl_passthru_hvcall()

From: Nuno Das Neves
Date: Fri Mar 21 2025 - 12:50:21 EST


On 3/21/2025 7:35 AM, Dan Carpenter wrote:
> The "ret" variable could be uninitialized on the success path depending
> on if "is_async" is true of false. Initialized it to zero.
>
> Fixes: f5288d14069b ("Drivers: hv: Introduce mshv_root module to expose /dev/mshv to VMMs")
> Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> ---
> drivers/hv/mshv_root_main.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/hv/mshv_root_main.c b/drivers/hv/mshv_root_main.c
> index 29fa6d5a3994..b94d8fe0f691 100644
> --- a/drivers/hv/mshv_root_main.c
> +++ b/drivers/hv/mshv_root_main.c
> @@ -151,13 +151,14 @@ static int mshv_ioctl_passthru_hvcall(struct mshv_partition *partition,
> void __user *user_args)
> {
> u64 status;
> - int ret, i;
> bool is_async;
> struct mshv_root_hvcall args;
> struct page *page;
> unsigned int pages_order;
> void *input_pg = NULL;
> void *output_pg = NULL;
> + int ret = 0;
> + int i;
>
> if (copy_from_user(&args, user_args, sizeof(args)))
> return -EFAULT;

Thanks Dan, I already sent a fixup for this:
https://lore.kernel.org/linux-hyperv/1742492693-21960-1-git-send-email-nunodasneves@xxxxxxxxxxxxxxxxxxx/