From patchwork Tue Oct 20 09:16:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 532861 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 8324D140281 for ; Tue, 20 Oct 2015 20:40:39 +1100 (AEDT) Received: from localhost ([::1]:44683 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZoT3Q-0002fe-SY for incoming@patchwork.ozlabs.org; Tue, 20 Oct 2015 05:18:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49130) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZoT2T-00026V-VB for qemu-devel@nongnu.org; Tue, 20 Oct 2015 05:17:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZoT2L-0005Ko-IT for qemu-devel@nongnu.org; Tue, 20 Oct 2015 05:16:56 -0400 Received: from e06smtp12.uk.ibm.com ([195.75.94.108]:45200) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZoT2L-0005KZ-8H for qemu-devel@nongnu.org; Tue, 20 Oct 2015 05:16:53 -0400 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 20 Oct 2015 10:16:51 +0100 Received: from d06dlp03.portsmouth.uk.ibm.com (9.149.20.15) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 20 Oct 2015 10:16:49 +0100 X-IBM-Helo: d06dlp03.portsmouth.uk.ibm.com X-IBM-MailFrom: gkurz@linux.vnet.ibm.com X-IBM-RcptTo: qemu-devel@nongnu.org; mst@redhat.com; afaerber@suse.de; agraf@suse.de Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 763DC1B0806E; Tue, 20 Oct 2015 10:16:56 +0100 (BST) Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t9K9GnOJ26607830; Tue, 20 Oct 2015 09:16:49 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4F84C52041; Tue, 20 Oct 2015 09:16:12 +0100 (BST) Received: from smtp.lab.toulouse-stg.fr.ibm.com (unknown [9.101.4.1]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 2C9DE5203D; Tue, 20 Oct 2015 09:16:12 +0100 (BST) Received: from bahia.huguette.org (icon-9-164-138-165.megacenter.de.ibm.com [9.164.138.165]) by smtp.lab.toulouse-stg.fr.ibm.com (Postfix) with ESMTP id D0FC3220083; Tue, 20 Oct 2015 11:16:47 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Tue, 20 Oct 2015 11:16:47 +0200 Message-ID: <20151020091647.25419.93971.stgit@bahia.huguette.org> In-Reply-To: <20151020091640.25419.99985.stgit@bahia.huguette.org> References: <20151020091640.25419.99985.stgit@bahia.huguette.org> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15102009-0009-0000-0000-0000065E5A96 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.75.94.108 Cc: Cornelia Huck , "Michael S. Tsirkin" , Alexander Graf , Andreas =?utf-8?q?F=C3=A4rber?= , aneesh.kumar@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH v3 1/5] virtio-9p-coth: fix init function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The v9fs thread pool is a singleton, shared by all virtio-9p devices. The current code leaks underlying glib pointers each time a new virtio-9p device gets realized. Let's fix that ! While we're here, we also fix the trivial error path when memory allocation is failing. Signed-off-by: Greg Kurz --- hw/9pfs/virtio-9p-coth.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/hw/9pfs/virtio-9p-coth.c b/hw/9pfs/virtio-9p-coth.c index 8185c533c013..1d832ede1ebf 100644 --- a/hw/9pfs/virtio-9p-coth.c +++ b/hw/9pfs/virtio-9p-coth.c @@ -55,6 +55,10 @@ int v9fs_init_worker_threads(void) V9fsThPool *p = &v9fs_pool; sigset_t set, oldset; + if (p->pool) { + return 0; + } + sigfillset(&set); /* Leave signal handling to the iothread. */ pthread_sigmask(SIG_SETMASK, &set, &oldset); @@ -66,10 +70,7 @@ int v9fs_init_worker_threads(void) } p->completed = g_async_queue_new(); if (!p->completed) { - /* - * We are going to terminate. - * So don't worry about cleanup - */ + g_thread_pool_free(p->pool, TRUE, TRUE); ret = -1; goto err_out; }