diff mbox series

[RFC,1/4] vdagent: fix memory leak when vdagent_disconnect is called

Message ID 20221230092758.281805-2-dengpc12@chinatelecom.cn (mailing list archive)
State New, archived
Headers show
Series vdagent: support live migration | expand

Commit Message

dengpc12@chinatelecom.cn Dec. 30, 2022, 9:27 a.m. UTC
From: "dengpc12@chinatelecom.cn" <dengpc12@chinatelecom.cn>

Memory free should be done in vdagent_disconnect using
qemu_input_handler_unregister, replace qemu_input_handler_deactivate
with that.

Signed-off-by: dengpc12@chinatelecom.cn <dengpc12@chinatelecom.cn>
Signed-off-by: liuym16@chinatelecom.cn <liuym16@chinatelecom.cn>
---
 ui/vdagent.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Marc-André Lureau Jan. 2, 2023, 11:29 a.m. UTC | #1
Hi

On Fri, Dec 30, 2022 at 6:48 PM <dengpc12@chinatelecom.cn> wrote:
>
> From: "dengpc12@chinatelecom.cn" <dengpc12@chinatelecom.cn>
>
> Memory free should be done in vdagent_disconnect using
> qemu_input_handler_unregister, replace qemu_input_handler_deactivate
> with that.
>
> Signed-off-by: dengpc12@chinatelecom.cn <dengpc12@chinatelecom.cn>
> Signed-off-by: liuym16@chinatelecom.cn <liuym16@chinatelecom.cn>
> ---
>  ui/vdagent.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/ui/vdagent.c b/ui/vdagent.c
> index 4bf50f0c4d..645383b4ec 100644
> --- a/ui/vdagent.c
> +++ b/ui/vdagent.c
> @@ -863,7 +863,7 @@ static void vdagent_disconnect(VDAgentChardev *vd)
>      vdagent_reset_bufs(vd);
>      vd->caps = 0;
>      if (vd->mouse_hs) {
> -        qemu_input_handler_deactivate(vd->mouse_hs);
> +        qemu_input_handler_unregister(vd->mouse_hs);

It looks like vdagent_disconnect() was meant to be called when the
agent connection is lost, vdagent_chr_set_fe_open(fe_open=false), so
it can later be initialized again during vdagent_chr_recv_caps(). Not
sure why this isn't done.

Imho, you should instead add qemu_input_handler_unregister() call to
vdagent_chr_fini() for now
diff mbox series

Patch

diff --git a/ui/vdagent.c b/ui/vdagent.c
index 4bf50f0c4d..645383b4ec 100644
--- a/ui/vdagent.c
+++ b/ui/vdagent.c
@@ -863,7 +863,7 @@  static void vdagent_disconnect(VDAgentChardev *vd)
     vdagent_reset_bufs(vd);
     vd->caps = 0;
     if (vd->mouse_hs) {
-        qemu_input_handler_deactivate(vd->mouse_hs);
+        qemu_input_handler_unregister(vd->mouse_hs);
     }
     if (vd->cbpeer.notifier.notify) {
         qemu_clipboard_peer_unregister(&vd->cbpeer);