From patchwork Mon Sep 17 08:26:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 10602223 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4971B6CB for ; Mon, 17 Sep 2018 08:45:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38DAD295CA for ; Mon, 17 Sep 2018 08:45:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D37129651; Mon, 17 Sep 2018 08:45:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C586729647 for ; Mon, 17 Sep 2018 08:45:46 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 80EC126788C; Mon, 17 Sep 2018 10:26:32 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 23D6B26788B; Mon, 17 Sep 2018 10:26:30 +0200 (CEST) Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by alsa0.perex.cz (Postfix) with ESMTP id 6DDB126780A for ; Mon, 17 Sep 2018 10:26:28 +0200 (CEST) Received: by mail-pg1-f193.google.com with SMTP id r1-v6so7292014pgp.11 for ; Mon, 17 Sep 2018 01:26:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=iH/NMlRyofQK2j2h8uGE1abpswJkL4qsWqn6MxQse7I=; b=cp+O5jiRDfmG7br9GJUmH52NeCGyYabcleHE24GP5YoCxcvJIfcQPImEjnBJeU+DU0 CnOdIzmhmsQv5VA3X9NS6gNN2C9QIlX3lrX9DmryysUnjoCvWT658g/LzXZC2FkFWJcX 4y3N/6yYLwMvr+4IKzYzX2ytlKp0kaH1nuixbbAMZqz+bP3kKUQ20Agv/m1PGft6mJJ+ ovlbsVkoDEpD6/ZQLkB4UfCXOqF2yMFi5uwSKeykS7Vb70iYkSRv1Vpadnktwi23Inhy xTvwz5cWa6QpQTPWTXPz6VBhBaaoUf2u6XpLwTzKmmf66S8JXFLtFJZjN2PiJqnVd9OP arxw== X-Gm-Message-State: APzg51CNNCmgxWiGXUK9T4jugTGZnlaXiAKDoPGoWKKiuaw2FQuYbezK Lse5tix5EFhW1Hc1ZBiqAMs= X-Google-Smtp-Source: ANB0Vdb+9CMsBoKAs/QquDJAaiMUMJOlxo3sWM/SfDbz5BeRS5NQYZjAxl6Hqje5/Hoe3tDGBKB1uA== X-Received: by 2002:a63:8442:: with SMTP id k63-v6mr19869116pgd.388.1537172787182; Mon, 17 Sep 2018 01:26:27 -0700 (PDT) Received: from localhost.localdomain ([2405:6580:9660:3200:60c7:933c:fe9f:29ca]) by smtp.gmail.com with ESMTPSA id v2-v6sm16391678pgf.58.2018.09.17.01.26.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Sep 2018 01:26:26 -0700 (PDT) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Mon, 17 Sep 2018 17:26:20 +0900 Message-Id: <20180917082620.11574-1-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.17.1 Cc: alsa-devel@alsa-project.org, stable@vger.kernel.org Subject: [alsa-devel] [PATCH] ALSA: oxfw: fix memory leak of discovered stream formats at error path X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP After finishing discover of stream formats, ALSA OXFW driver has memory leak of allocated memory object at error path. This commit releases the memory object at the error path. Fixes: 6c29230e2a5f ('ALSA: oxfw: delayed registration of sound card') Cc: # v4.7+ Signed-off-by: Takashi Sakamoto --- sound/firewire/oxfw/oxfw.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sound/firewire/oxfw/oxfw.c b/sound/firewire/oxfw/oxfw.c index 1e5b2c802635..63b3e1ce986e 100644 --- a/sound/firewire/oxfw/oxfw.c +++ b/sound/firewire/oxfw/oxfw.c @@ -207,6 +207,7 @@ static int detect_quirks(struct snd_oxfw *oxfw) static void do_registration(struct work_struct *work) { struct snd_oxfw *oxfw = container_of(work, struct snd_oxfw, dwork.work); + int i; int err; if (oxfw->registered) @@ -269,6 +270,12 @@ static void do_registration(struct work_struct *work) snd_oxfw_stream_destroy_simplex(oxfw, &oxfw->rx_stream); if (oxfw->has_output) snd_oxfw_stream_destroy_simplex(oxfw, &oxfw->tx_stream); + for (i = 0; i < SND_OXFW_STREAM_FORMAT_ENTRIES; ++i) { + kfree(oxfw->tx_stream_formats[i]); + oxfw->tx_stream_formats[i] = NULL; + kfree(oxfw->rx_stream_formats[i]); + oxfw->rx_stream_formats[i] = NULL; + } snd_card_free(oxfw->card); dev_info(&oxfw->unit->device, "Sound card registration failed: %d\n", err);