mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Naman Jain <namjain@linux.microsoft.com>
To: Andrey Misiurov <amisiurov@cloudlinux.com>,
	Haiyang Zhang <haiyangz@microsoft.com>,
	Wei Liu <wei.liu@kernel.org>, Dexuan Cui <decui@microsoft.com>
Cc: Michael Kelley <mhklinux@outlook.com>,
	linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH] Drivers: hv: util: Fix transport teardown on util_probe() failure
Date: Thu, 5 Nov 2026 14:44:32 +0530	[thread overview]
Message-ID: <d3764ad4-9c95-470a-a3c2-474600657405@linux.microsoft.com> (raw)
In-Reply-To: <20261104203049.1031148-1-amisiurov@cloudlinux.com>



On 11/5/2026 2:00 AM, Andrey Misiurov wrote:
> Commit 07a756a49f4b ("Drivers: hv: util: Avoid accessing a ringbuffer
> not initialized yet") moved the creation of the KVP and VSS transports
> after vmbus_open(). util_probe() still calls srv->util_deinit() when
> vmbus_open() or util_init_transport() fails, and hv_kvp_deinit() and
> hv_vss_deinit() destroy hvt unconditionally.
> 
> On the first probe, or when hvutil_transport_init() has failed, hvt is
> NULL and hvutil_transport_destroy() dereferences it.  After an unbind,
> hvt still points to the transport freed by util_remove(), so a failed
> re-probe frees it a second time.
> 
> Skip the destroy when there is no transport and clear hvt after it.
> 
> Found while reviewing a backport of commit 07a756a49f4b.
> Not reproduced at runtime.
> 

Ideally above 2 lines should go as comments in this patch here [1]. 
Keeping that nit aside, this LGTM.

Reviewed-by: Naman Jain <namjain@linux.microsoft.com>


> Fixes: 07a756a49f4b ("Drivers: hv: util: Avoid accessing a ringbuffer not initialized yet")
> Cc: stable@vger.kernel.org
> Signed-off-by: Andrey Misiurov <amisiurov@cloudlinux.com>
> ---

[1].

>   drivers/hv/hv_kvp.c      | 5 ++++-
>   drivers/hv/hv_snapshot.c | 5 ++++-
>   2 files changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hv/hv_kvp.c b/drivers/hv/hv_kvp.c
> index 336b278..813bec5 100644
> --- a/drivers/hv/hv_kvp.c
> +++ b/drivers/hv/hv_kvp.c
> @@ -825,5 +825,8 @@ void hv_kvp_deinit(void)
>   
>   	hv_kvp_cancel_work();
>   
> -	hvutil_transport_destroy(hvt);
> +	if (hvt) {
> +		hvutil_transport_destroy(hvt);
> +		hvt = NULL;
> +	}
>   }
> diff --git a/drivers/hv/hv_snapshot.c b/drivers/hv/hv_snapshot.c
> index 847dc69..a827cef 100644
> --- a/drivers/hv/hv_snapshot.c
> +++ b/drivers/hv/hv_snapshot.c
> @@ -456,5 +456,8 @@ void hv_vss_deinit(void)
>   
>   	hv_vss_cancel_work();
>   
> -	hvutil_transport_destroy(hvt);
> +	if (hvt) {
> +		hvutil_transport_destroy(hvt);
> +		hvt = NULL;
> +	}
>   }

Regards,
Naman

      reply	other threads:[~2026-11-05  9:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-04 20:30 Andrey Misiurov
2026-11-05  9:14 ` Naman Jain [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d3764ad4-9c95-470a-a3c2-474600657405@linux.microsoft.com \
    --to=namjain@linux.microsoft.com \
    --cc=amisiurov@cloudlinux.com \
    --cc=decui@microsoft.com \
    --cc=haiyangz@microsoft.com \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhklinux@outlook.com \
    --cc=stable@vger.kernel.org \
    --cc=wei.liu@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®