From patchwork Thu Sep 29 17:32:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin King X-Patchwork-Id: 9356827 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0F48A6077A for ; Thu, 29 Sep 2016 17:35:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 00BD629B10 for ; Thu, 29 Sep 2016 17:35:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E800E29B56; Thu, 29 Sep 2016 17:35:39 +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=-1.9 required=2.0 tests=BAYES_00, 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 99BDD29BD9 for ; Thu, 29 Sep 2016 17:35:37 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 3BF2B2654BC; Thu, 29 Sep 2016 19:35:36 +0200 (CEST) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 03DE2265119; Thu, 29 Sep 2016 19:33:12 +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 C038B26513F; Thu, 29 Sep 2016 19:33:01 +0200 (CEST) Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by alsa0.perex.cz (Postfix) with ESMTP id 956AB264EFA for ; Thu, 29 Sep 2016 19:32:56 +0200 (CEST) Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1bpfBt-0002Pt-A1; Thu, 29 Sep 2016 17:32:13 +0000 From: Colin King To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Vinod Koul , Dharageswari R , Senthilnathan Veppur , Shreyas NC , Ramesh Babu , alsa-devel@alsa-project.org Date: Thu, 29 Sep 2016 18:32:12 +0100 Message-Id: <20160929173212.13700-1-colin.king@canonical.com> X-Mailer: git-send-email 2.9.3 MIME-Version: 1.0 Cc: linux-kernel@vger.kernel.org Subject: [alsa-devel] [PATCH] ASoC: Intel: Skylake: fix memory leak of module on error exit 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP From: Colin Ian King Currently there is a memory leak of module on a ENOMEM return path. Fix this by kfree'ing module before returning. Signed-off-by: Colin Ian King --- sound/soc/intel/skylake/skl-sst-utils.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sound/soc/intel/skylake/skl-sst-utils.c b/sound/soc/intel/skylake/skl-sst-utils.c index d3120ba..8dc0303 100644 --- a/sound/soc/intel/skylake/skl-sst-utils.c +++ b/sound/soc/intel/skylake/skl-sst-utils.c @@ -354,8 +354,10 @@ int snd_skl_parse_uuids(struct sst_dsp *ctx, const struct firmware *fw, module->max_instance = mod_entry->instance_max_count; size = sizeof(int) * mod_entry->instance_max_count; module->instance_id = devm_kzalloc(ctx->dev, size, GFP_KERNEL); - if (!module->instance_id) + if (!module->instance_id) { + kfree(module); return -ENOMEM; + } list_add_tail(&module->list, &skl->uuid_list);