[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 6/8] chardev: fix segfault in finalize
From: |
marcandre . lureau |
Subject: |
[PULL 6/8] chardev: fix segfault in finalize |
Date: |
Thu, 29 Sep 2022 15:05:06 +0400 |
From: Maksim Davydov <davydov-max@yandex-team.ru>
If finalize chardev-msmouse or chardev-wctable is called immediately after
init it cases QEMU to crash with segfault. This happens because of
QTAILQ_REMOVE in qemu_input_handler_unregister tries to dereference
NULL pointer.
For instance, this error can be reproduced via `qom-list-properties`
command.
Signed-off-by: Maksim Davydov <davydov-max@yandex-team.ru>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Message-Id: <20220825165247.33704-1-davydov-max@yandex-team.ru>
---
chardev/msmouse.c | 4 +++-
chardev/wctablet.c | 4 +++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/chardev/msmouse.c b/chardev/msmouse.c
index 9006703023..ab8fe981d6 100644
--- a/chardev/msmouse.c
+++ b/chardev/msmouse.c
@@ -247,7 +247,9 @@ static void char_msmouse_finalize(Object *obj)
{
MouseChardev *mouse = MOUSE_CHARDEV(obj);
- qemu_input_handler_unregister(mouse->hs);
+ if (mouse->hs) {
+ qemu_input_handler_unregister(mouse->hs);
+ }
fifo8_destroy(&mouse->outbuf);
}
diff --git a/chardev/wctablet.c b/chardev/wctablet.c
index e8b292c43c..43bdf6b608 100644
--- a/chardev/wctablet.c
+++ b/chardev/wctablet.c
@@ -319,7 +319,9 @@ static void wctablet_chr_finalize(Object *obj)
{
TabletChardev *tablet = WCTABLET_CHARDEV(obj);
- qemu_input_handler_unregister(tablet->hs);
+ if (tablet->hs) {
+ qemu_input_handler_unregister(tablet->hs);
+ }
}
static void wctablet_chr_open(Chardev *chr,
--
2.37.3
- [PULL 0/8] chardev patches, marcandre . lureau, 2022/09/29
- [PULL 1/8] msmouse: Handle mouse reset, marcandre . lureau, 2022/09/29
- [PULL 2/8] chardev: src buffer const for write functions, marcandre . lureau, 2022/09/29
- [PULL 3/8] msmouse: Use fifo8 instead of array, marcandre . lureau, 2022/09/29
- [PULL 4/8] msmouse: Add pnp data, marcandre . lureau, 2022/09/29
- [PULL 6/8] chardev: fix segfault in finalize,
marcandre . lureau <=
- [PULL 5/8] serial: Allow unaligned i/o access, marcandre . lureau, 2022/09/29
- [PULL 8/8] vhost-user: Call qemu_socketpair() instead of socketpair(), marcandre . lureau, 2022/09/29
- [PULL 7/8] oslib-posix: Introduce qemu_socketpair(), marcandre . lureau, 2022/09/29