From patchwork Tue Mar 24 06:18:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Volker_R=C3=BCmelin?= X-Patchwork-Id: 1260482 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=t-online.de Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48mh151dBkz9sNg for ; Tue, 24 Mar 2020 17:19:37 +1100 (AEDT) Received: from localhost ([::1]:43602 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jGcuV-0001qG-78 for incoming@patchwork.ozlabs.org; Tue, 24 Mar 2020 02:19:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46082) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jGcu6-0001q9-Fm for qemu-devel@nongnu.org; Tue, 24 Mar 2020 02:19:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jGcu5-0000ng-Ck for qemu-devel@nongnu.org; Tue, 24 Mar 2020 02:19:10 -0400 Received: from mailout04.t-online.de ([194.25.134.18]:34342) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jGcu5-0000lT-6t for qemu-devel@nongnu.org; Tue, 24 Mar 2020 02:19:09 -0400 Received: from fwd06.aul.t-online.de (fwd06.aul.t-online.de [172.20.26.150]) by mailout04.t-online.de (Postfix) with SMTP id 392CC41BADFA; Tue, 24 Mar 2020 07:19:06 +0100 (CET) Received: from linpower.localnet (TWfXKUZSgh-qC9Pqk75CBSp5AMWVhwG5RYzIRcAu35kWBp1YYHu1gDzjUk6inBgQ7S@[93.236.151.78]) by fwd06.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1jGcts-2IEPPU0; Tue, 24 Mar 2020 07:18:56 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id DA3E7200F49; Tue, 24 Mar 2020 07:18:55 +0100 (CET) From: =?utf-8?q?Volker_R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH] hw/audio/fmopl: fix segmentation fault Date: Tue, 24 Mar 2020 07:18:55 +0100 Message-Id: <20200324061855.5951-1-vr_qemu@t-online.de> X-Mailer: git-send-email 2.16.4 MIME-Version: 1.0 X-ID: TWfXKUZSgh-qC9Pqk75CBSp5AMWVhwG5RYzIRcAu35kWBp1YYHu1gDzjUk6inBgQ7S X-TOI-MSGID: 61372906-d5a0-48ce-8152-3dbf625e179d X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 194.25.134.18 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , QEMU Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Current code allocates the memory for ENV_CURVE too late. Move allocation to OPLOpenTable() and deallocation to OPLCloseTable(). To reproduce the bug start qemu with -soundhw adlib. Fixes 2eea51bd01 "hw/audio/fmopl: Move ENV_CURVE to .heap to save 32KiB of .bss" Signed-off-by: Volker Rümelin Reviewed-by: Philippe Mathieu-Daudé --- hw/audio/fmopl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/audio/fmopl.c b/hw/audio/fmopl.c index 356d4dfbca..8a71a569fa 100644 --- a/hw/audio/fmopl.c +++ b/hw/audio/fmopl.c @@ -627,6 +627,7 @@ static int OPLOpenTable( void ) free(AMS_TABLE); return 0; } + ENV_CURVE = g_new(int32_t, 2 * EG_ENT + 1); /* make total level table */ for (t = 0;t < EG_ENT-1 ;t++){ rate = ((1< voltage */ @@ -694,6 +695,7 @@ static int OPLOpenTable( void ) static void OPLCloseTable( void ) { + g_free(ENV_CURVE); free(TL_TABLE); free(SIN_TABLE); free(AMS_TABLE); @@ -1090,7 +1092,6 @@ FM_OPL *OPLCreate(int clock, int rate) OPL->clock = clock; OPL->rate = rate; OPL->max_ch = max_ch; - ENV_CURVE = g_new(int32_t, 2 * EG_ENT + 1); /* init grobal tables */ OPL_initialize(OPL); /* reset chip */ @@ -1128,7 +1129,6 @@ void OPLDestroy(FM_OPL *OPL) #endif OPL_UnLockTable(); free(OPL); - g_free(ENV_CURVE); } /* ---------- Option handlers ---------- */