]> git.proxmox.com Git - qemu.git/commitdiff
iohandlers: fix issue with qemu_set_fd_handler()
authorAnthony Liguori <aliguori@us.ibm.com>
Wed, 7 Sep 2011 18:44:45 +0000 (13:44 -0500)
committerAnthony Liguori <aliguori@us.ibm.com>
Thu, 8 Sep 2011 13:06:08 +0000 (08:06 -0500)
As spotted by Aneesh, some users pass a NULL opaque so we need to be more
aggressive in checking whether a user means to unregister.

Also fix a double free caused by tag not being reset to zero after delete.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
iohandler.c

index 5ef66fb6e8746a3707bec8b736e7ce55140a2754..4cc1c5ade616eedb5c5687e9b62a7c7b4d187e31 100644 (file)
@@ -93,10 +93,6 @@ static gboolean fd_trampoline(GIOChannel *chan, GIOCondition cond, gpointer opaq
 {
     IOTrampoline *tramp = opaque;
 
-    if (tramp->opaque == NULL) {
-        return FALSE;
-    }
-
     if ((cond & G_IO_IN) && tramp->fd_read) {
         tramp->fd_read(tramp->opaque);
     }
@@ -119,9 +115,10 @@ int qemu_set_fd_handler(int fd,
     if (tramp->tag != 0) {
         g_io_channel_unref(tramp->chan);
         g_source_remove(tramp->tag);
+        tramp->tag = 0;
     }
 
-    if (opaque) {
+    if (fd_read || fd_write || opaque) {
         GIOCondition cond = 0;
 
         tramp->fd_read = fd_read;