[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 09/18] ui/vdagent: disconnect handlers and reset state on fina
From: |
marcandre . lureau |
Subject: |
[PATCH v3 09/18] ui/vdagent: disconnect handlers and reset state on finalize |
Date: |
Thu, 5 Aug 2021 17:57:06 +0400 |
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Avoid handlers being called with dangling pointers when the object is
freed.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
ui/vdagent.c | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/ui/vdagent.c b/ui/vdagent.c
index 5ae5734c81..1a29016e07 100644
--- a/ui/vdagent.c
+++ b/ui/vdagent.c
@@ -721,22 +721,26 @@ static void vdagent_chr_accept_input(Chardev *chr)
vdagent_send_buf(vd);
}
+static void vdagent_disconnect(VDAgentChardev *vd)
+{
+ vdagent_reset_bufs(vd);
+ vd->caps = 0;
+ if (vd->mouse_hs) {
+ qemu_input_handler_deactivate(vd->mouse_hs);
+ }
+ if (vd->cbpeer.update.notify) {
+ qemu_clipboard_peer_unregister(&vd->cbpeer);
+ memset(&vd->cbpeer, 0, sizeof(vd->cbpeer));
+ }
+}
+
static void vdagent_chr_set_fe_open(struct Chardev *chr, int fe_open)
{
VDAgentChardev *vd = QEMU_VDAGENT_CHARDEV(chr);
if (!fe_open) {
trace_vdagent_close();
- /* reset state */
- vdagent_reset_bufs(vd);
- vd->caps = 0;
- if (vd->mouse_hs) {
- qemu_input_handler_deactivate(vd->mouse_hs);
- }
- if (vd->cbpeer.update.notify) {
- qemu_clipboard_peer_unregister(&vd->cbpeer);
- memset(&vd->cbpeer, 0, sizeof(vd->cbpeer));
- }
+ vdagent_disconnect(vd);
return;
}
@@ -781,6 +785,7 @@ static void vdagent_chr_fini(Object *obj)
{
VDAgentChardev *vd = QEMU_VDAGENT_CHARDEV(obj);
+ vdagent_disconnect(vd);
buffer_free(&vd->outbuf);
}
--
2.32.0.264.g75ae10bc75
- [PATCH v3 00/18] Clipboard fixes (for 6.1?), marcandre . lureau, 2021/08/05
- [PATCH v3 01/18] ui/vdagent: fix leak on error path, marcandre . lureau, 2021/08/05
- [PATCH v3 02/18] ui/vdagent: remove copy-pasta comment, marcandre . lureau, 2021/08/05
- [PATCH v3 03/18] ui/gtk-clipboard: use existing macros, marcandre . lureau, 2021/08/05
- [PATCH v3 04/18] ui/gtk-clipboard: fix clipboard enum typo, marcandre . lureau, 2021/08/05
- [PATCH v3 05/18] ui/clipboard: add helper to retrieve current clipboard, marcandre . lureau, 2021/08/05
- [PATCH v3 06/18] ui/clipboard: add qemu_clipboard_peer_owns() helper, marcandre . lureau, 2021/08/05
- [PATCH v3 07/18] ui/clipboard: add qemu_clipboard_peer_release() helper, marcandre . lureau, 2021/08/05
- [PATCH v3 08/18] ui/clipboard: release owned grabs on unregister, marcandre . lureau, 2021/08/05
- [PATCH v3 09/18] ui/vdagent: disconnect handlers and reset state on finalize,
marcandre . lureau <=
- [PATCH v3 10/18] ui/vdagent: reset outbuf on disconnect, marcandre . lureau, 2021/08/05
- [PATCH v3 11/18] ui/vdagent: split clipboard recv message handling, marcandre . lureau, 2021/08/05
- [PATCH v3 12/18] ui/vdagent: use qemu_clipboard_peer_release helper, marcandre . lureau, 2021/08/05
- [PATCH v3 13/18] ui/vdagent: use qemu_clipboard_info helper, marcandre . lureau, 2021/08/05
- [PATCH v3 14/18] ui/vdagent: send empty clipboard when unhandled, marcandre . lureau, 2021/08/05
- [PATCH v3 15/18] ui/gtk-clipboard: use qemu_clipboard_info helper, marcandre . lureau, 2021/08/05
- [PATCH v3 16/18] ui/vdagent: send release when no clipboard owner, marcandre . lureau, 2021/08/05
- [PATCH v3 17/18] ui/gtk-clipboard: emit release clipboard events, marcandre . lureau, 2021/08/05
- [PATCH v3 18/18] ui/vdagent: add a migration blocker, marcandre . lureau, 2021/08/05