From patchwork Tue Sep 1 05:44:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 7102781 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3AA529F32B for ; Tue, 1 Sep 2015 05:46:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5C92B204D1 for ; Tue, 1 Sep 2015 05:46:32 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 1F8C3204B0 for ; Tue, 1 Sep 2015 05:46:31 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 05F75261AF0; Tue, 1 Sep 2015 07:46:29 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id CF300262618; Tue, 1 Sep 2015 07:45:29 +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 DD180264F02; Tue, 1 Sep 2015 07:45:27 +0200 (CEST) Received: from mail-pa0-f50.google.com (mail-pa0-f50.google.com [209.85.220.50]) by alsa0.perex.cz (Postfix) with ESMTP id E9E3E264F40 for ; Tue, 1 Sep 2015 07:44:15 +0200 (CEST) Received: by pacdd16 with SMTP id dd16so164250788pac.2 for ; Mon, 31 Aug 2015 22:44:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=SVJt1IBHakROZDjQU92pYlwUXS4NWmMYRu3pX7nKarI=; b=mr+lzyWF8UPhkHOGSGNoJMwunvNwN/44jmizs+jMlQOptXhB6hxGb4QIy4XFQmfkyP hHoJ+xsPfozy3ZjjPOaTvUTyVaithelO6O/dlMxOVjHcvqjDd2rtseaXcjaD77N12mw3 UYC5diBuAsoQVJQlgK0f9OHbVZADwJ171/1gWqfT32nYmrhWRAiCGebpGtBO4BMw5zQB FyTpPr27ulh5GzvkWKM5JkN1y78udwtovaT7kGXbGQMquVwNUYgWIx6YGLPvg7OijhuL 2eJ/TkHb4tP4vLwpx561lLhQjLdx1Ss8cD7tY978NrCJsYO7SKqKdI73P3N5NycMMtus r5sg== X-Received: by 10.68.178.1 with SMTP id cu1mr44124200pbc.1.1441086255648; Mon, 31 Aug 2015 22:44:15 -0700 (PDT) Received: from localhost.localdomain ([122.169.183.241]) by smtp.gmail.com with ESMTPSA id xo14sm16692411pac.24.2015.08.31.22.44.12 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 31 Aug 2015 22:44:15 -0700 (PDT) From: Sudip Mukherjee To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai Date: Tue, 1 Sep 2015 11:14:05 +0530 Message-Id: <1441086245-14732-1-git-send-email-sudipm.mukherjee@gmail.com> X-Mailer: git-send-email 1.9.1 Cc: alsa-devel@alsa-project.org, patches@opensource.wolfsonmicro.com, linux-kernel@vger.kernel.org, Sudip Mukherjee Subject: [alsa-devel] [PATCH] ASoC: wm0010: fix memory leak 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 We were aborting if the kzalloc of img_swap fails but without freeing the already allocated out. Similarly we were aborting if spi_sync fails without releasing out and img_swap. Signed-off-by: Sudip Mukherjee Acked-by: Charles Keepax --- sound/soc/codecs/wm0010.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/wm0010.c b/sound/soc/codecs/wm0010.c index f2c6ad4..8434d45 100644 --- a/sound/soc/codecs/wm0010.c +++ b/sound/soc/codecs/wm0010.c @@ -672,8 +672,10 @@ static int wm0010_boot(struct snd_soc_codec *codec) } img_swap = kzalloc(len, GFP_KERNEL | GFP_DMA); - if (!img_swap) + if (!img_swap) { + kfree(out); goto abort; + } /* We need to re-order for 0010 */ byte_swap_64((u64 *)&pll_rec, img_swap, len); @@ -690,6 +692,8 @@ static int wm0010_boot(struct snd_soc_codec *codec) ret = spi_sync(spi, &m); if (ret != 0) { dev_err(codec->dev, "First PLL write failed: %d\n", ret); + kfree(img_swap); + kfree(out); goto abort; } @@ -697,6 +701,8 @@ static int wm0010_boot(struct snd_soc_codec *codec) ret = spi_sync(spi, &m); if (ret != 0) { dev_err(codec->dev, "Second PLL write failed: %d\n", ret); + kfree(img_swap); + kfree(out); goto abort; }