Skip to contentSkip to conversation

iothread: check iothread->ctx before aio_context_unref to avoid assertion

PATCH Applied Lin Ma 3 participants 3 messages Sep 26, 2016

lore
Share & tools
lore

Lin Ma

author
#0 lore raw

PATCH 1/1 iothread: check iothread->ctx before aio_context_unref to avoid assertion

if iothread->ctx is set to NULL, aio_context_unref triggers the assertion:
g_source_unref: assertion 'source != NULL' failed.
The patch fixes it.

---
 iothread.c | 3 +++
 1 file changed, 3 insertions(+)
iothread.c +3 -0
index fb08a60..fbeb8de 100644
@@ -75,6 +75,9 @@ static void iothread_instance_finalize(Object *obj)
     iothread_stop(obj, NULL);
     qemu_cond_destroy(&iothread->init_done_cond);
     qemu_mutex_destroy(&iothread->init_done_lock);
+    if (!iothread->ctx) {
+        return;
+    }
     aio_context_unref(iothread->ctx);
 }
 
Signature · 1 line
2.9.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 15 lines · Lin Ma

if iothread->ctx is set to NULL, aio_context_unref triggers the assertion:
g_source_unref: assertion 'source != NULL' failed.
The patch fixes it.

---
 iothread.c | 3 +++
 1 file changed, 3 insertions(+)
iothread.c +0 -0
index fb08a60..fbeb8de 100644

iothread.c static void iothread_instance_finalize(Object *obj) · line 83

Quoted 9 lines
iothread.c +3 -0
@@ -75,6 +75,9 @@ static void iothread_instance_finalize(Object *obj)
     iothread_stop(obj, NULL);
     qemu_cond_destroy(&iothread->init_done_cond);
     qemu_mutex_destroy(&iothread->init_done_lock);
+    if (!iothread->ctx) {
+        return;
+    }
     aio_context_unref(iothread->ctx);
 }
 

This only happens if there is an error, but it's theoretically possible.