From patchwork Tue Jun 9 10:47:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 482177 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 1DA6B140562 for ; Tue, 9 Jun 2015 20:48:28 +1000 (AEST) Received: from localhost ([::1]:34238 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z2H4z-00030U-Rl for incoming@patchwork.ozlabs.org; Tue, 09 Jun 2015 06:48:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49710) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z2H4K-0001vS-H4 for qemu-devel@nongnu.org; Tue, 09 Jun 2015 06:47:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z2H4I-0004eA-C5 for qemu-devel@nongnu.org; Tue, 09 Jun 2015 06:47:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51854) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z2H4I-0004dp-78 for qemu-devel@nongnu.org; Tue, 09 Jun 2015 06:47:42 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id C59F38E3C4; Tue, 9 Jun 2015 10:47:41 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-58.ams2.redhat.com [10.36.116.58]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t59AleOZ017613; Tue, 9 Jun 2015 06:47:41 -0400 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id 029AE81857; Tue, 9 Jun 2015 12:47:36 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 9 Jun 2015 12:47:28 +0200 Message-Id: <1433846851-20552-10-git-send-email-kraxel@redhat.com> In-Reply-To: <1433846851-20552-1-git-send-email-kraxel@redhat.com> References: <1433846851-20552-1-git-send-email-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: "Vassili Karpov \(malc\)" , Gerd Hoffmann , =?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?= Subject: [Qemu-devel] [PULL 09/12] paaudio: fix possible resource leak 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 From: Kővágó, Zoltán qpa_audio_init did not clean up resources properly if the initialization failed. This hopefully fixes it. Signed-off-by: Kővágó, Zoltán Signed-off-by: Gerd Hoffmann --- audio/paaudio.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/audio/paaudio.c b/audio/paaudio.c index 35e8887..fea6071 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -47,6 +47,8 @@ typedef struct { paaudio *g; } PAVoiceIn; +static void qpa_audio_fini(void *opaque); + static void GCC_FMT_ATTR (2, 3) qpa_logerr (int err, const char *fmt, ...) { va_list ap; @@ -814,6 +816,8 @@ static void *qpa_audio_init (void) { paaudio *g = g_malloc(sizeof(paaudio)); g->conf = glob_conf; + g->mainloop = NULL; + g->context = NULL; g->mainloop = pa_threaded_mainloop_new (); if (!g->mainloop) { @@ -867,7 +871,7 @@ unlock_and_fail: pa_threaded_mainloop_unlock (g->mainloop); fail: AUD_log (AUDIO_CAP, "Failed to initialize PA context"); - g_free(g); + qpa_audio_fini(g); return NULL; }