Received: from eggs.gnu.org ([2001:4830:134:3::10]:57545) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1boQ0Z-0001ED-2e for qemu-devel@nongnu.org; Mon, 26 Sep 2016 03:07:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1boQ0V-0006fh-1Q for qemu-devel@nongnu.org; Mon, 26 Sep 2016 03:07:22 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:32824) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1boQ0U-0006fN-Qh for qemu-devel@nongnu.org; Mon, 26 Sep 2016 03:07:18 -0400 Received: by mail-wm0-f65.google.com with SMTP id w84so12560474wmg.0 for ; Mon, 26 Sep 2016 00:07:18 -0700 (PDT) Sender: Paolo Bonzini References: <20160926052958.10716-1-lma@suse.com> From: Paolo Bonzini Message-ID: <7d94ae26-5eb5-5213-ce41-dd829fe9c135@redhat.com> Date: Mon, 26 Sep 2016 09:06:16 +0200 MIME-Version: 1.0 In-Reply-To: <20160926052958.10716-1-lma@suse.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] iothread: check iothread->ctx before aio_context_unref to avoid assertion List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Lin Ma , qemu-devel@nongnu.org Cc: famz@redhat.com, stefanha@redhat.com On 26/09/2016 07:29, Lin Ma wrote: > if iothread->ctx is set to NULL, aio_context_unref triggers the assertion: > g_source_unref: assertion 'source != NULL' failed. > The patch fixes it. > > Signed-off-by: Lin Ma > --- > iothread.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/iothread.c b/iothread.c > index fb08a60..fbeb8de 100644 > --- a/iothread.c > +++ b/iothread.c > @@ -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. Reviewed-by: Paolo Bonzini