From: John Levon <john.levon@nutanix.com>
To: zhaoguohan@kylinos.cn
Cc: "Thanos Makatos" <thanos.makatos@nutanix.com>,
"Cédric Le Goater" <clg@redhat.com>,
qemu-devel@nongnu.org
Subject: Re: [PATCH] vfio-user: disconnect container when device info query fails
Date: Tue, 26 May 2026 09:51:35 +0100 [thread overview]
Message-ID: <ahVfF6LF9kHk05Z_@lent> (raw)
In-Reply-To: <20260522065637.4109499-1-zhaoguohan@kylinos.cn>
On Fri, May 22, 2026 at 02:56:37PM +0800, zhaoguohan@kylinos.cn wrote:
> vfio_user_device_attach() connects the vfio-user container before querying
> VFIO_USER_DEVICE_GET_INFO. If the device info query fails,
> vfio_device_prepare() has not run yet, so vbasedev->bcontainer is still
> NULL and the later vfio_device_detach() cleanup path cannot reach the new
> container.
>
> Disconnect the container before returning the attach failure so the listener,
> RAM discard state, object reference and address space reference are released
> on this error path.
>
> Signed-off-by: GuoHan Zhao <zhaoguohan@kylinos.cn>
> ---
> hw/vfio-user/container.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/hw/vfio-user/container.c b/hw/vfio-user/container.c
> index 796289a46903..dc23b06eebf1 100644
> --- a/hw/vfio-user/container.c
> +++ b/hw/vfio-user/container.c
> @@ -309,7 +309,12 @@ static bool vfio_user_device_attach(const char *name, VFIODevice *vbasedev,
> return false;
> }
>
> - return vfio_user_device_get(container, vbasedev, errp);
> + if (!vfio_user_device_get(container, vbasedev, errp)) {
> + vfio_user_container_disconnect(container);
> + return false;
> + }
> +
> + return true;
> }
>
> static void vfio_user_device_detach(VFIODevice *vbasedev)
Reviewed-by: John Levon <john.levon@nutanix.com>
prev parent reply other threads:[~2026-05-26 8:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-22 6:56 [PATCH] vfio-user: disconnect container when device info query fails zhaoguohan
2026-05-26 8:51 ` John Levon [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=ahVfF6LF9kHk05Z_@lent \
--to=john.levon@nutanix.com \
--cc=clg@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=thanos.makatos@nutanix.com \
--cc=zhaoguohan@kylinos.cn \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.