From patchwork Sat Aug 29 15:09:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 7095391 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 7C52D9F1B9 for ; Sat, 29 Aug 2015 15:10:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 405082068D for ; Sat, 29 Aug 2015 15:09:55 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id B1C8A20688 for ; Sat, 29 Aug 2015 15:09:53 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 6C9DF2606C7; Sat, 29 Aug 2015 17:09:51 +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.6 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM, RCVD_IN_DNSWL_LOW, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 5497126067A; Sat, 29 Aug 2015 17:09:44 +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 EC41626067B; Sat, 29 Aug 2015 17:09:42 +0200 (CEST) Received: from mail-pa0-f52.google.com (mail-pa0-f52.google.com [209.85.220.52]) by alsa0.perex.cz (Postfix) with ESMTP id 84DEC260671 for ; Sat, 29 Aug 2015 17:09:35 +0200 (CEST) Received: by padhm10 with SMTP id hm10so36242178pad.3 for ; Sat, 29 Aug 2015 08:09:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:subject:from:to:cc:date:content-type :mime-version:content-transfer-encoding; bh=6CHEdVU0ZX9waH94aCBaDklOslOU5uUmVcad+B/MErI=; b=afow8JZQMIKQ6Pzue4/Uc8jpmk2g+SfmbD3Bn8B65jIdhNX2ExJe7ToJqtHuBDg8nY LKRZspwzEIBMogsj8cmMVIJGKr5YiDCbGBt/2io/1Ap+FhrO8tnrDX7U9svWg/cOLB/O o82v6u8fTAlqtX3i/por0kFW0ZzcQ3kNTQzZrNiXzlSZ5Ggu8vtSlSPXtul0jl3B4LTx oB271ATmeyF+2L5HmbbnLjC4FhgkNVR0YWFKZXGcnFgP1lZ7+UjKTJpCt3wYb9cYXj4U hd5bu/iagz/2kT/jsMmZjIGBfcp97WOxJ1RGFU3b9sgG9AM0a/ZzxhvxiEbfxGcAqERU Ywjw== X-Gm-Message-State: ALoCoQk6c3dAgY+TUzckwNB5da4bFmNkmasp4PpCmybhfkzXaz6Tw801aFpYjPWI0kbGv8PLJEZ8 X-Received: by 10.68.197.196 with SMTP id iw4mr23526175pbc.153.1440860974670; Sat, 29 Aug 2015 08:09:34 -0700 (PDT) Received: from phoenix.local (218-164-130-19.dynamic.hinet.net. [218.164.130.19]) by smtp.gmail.com with ESMTPSA id fl6sm8998162pab.12.2015.08.29.08.09.32 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 29 Aug 2015 08:09:33 -0700 (PDT) Message-ID: <1440860970.28601.2.camel@ingics.com> From: Axel Lin To: Mark Brown Date: Sat, 29 Aug 2015 23:09:30 +0800 X-Mailer: Evolution 3.12.10-0ubuntu1~14.10.1 Mime-Version: 1.0 Cc: Jun Nie , Liam Girdwood , alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH] ASoC: zx296702-i2s: Fix resource leak when unload module 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 Use devm_* API to fix leaks in current code. 1. Use devm_kzalloc to fix memory leak for zx_i2s when unload the module. 2. Use devm_snd_soc_register_component to ensure component is unregistered when unload the module. Signed-off-by: Axel Lin Reviewed-by: Jun Nie --- sound/soc/zte/zx296702-i2s.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/soc/zte/zx296702-i2s.c b/sound/soc/zte/zx296702-i2s.c index 1930c42..1cad93d 100644 --- a/sound/soc/zte/zx296702-i2s.c +++ b/sound/soc/zte/zx296702-i2s.c @@ -380,7 +380,7 @@ static int zx_i2s_probe(struct platform_device *pdev) struct zx_i2s_info *zx_i2s; int ret; - zx_i2s = kzalloc(sizeof(*zx_i2s), GFP_KERNEL); + zx_i2s = devm_kzalloc(&pdev->dev, sizeof(*zx_i2s), GFP_KERNEL); if (!zx_i2s) return -ENOMEM; @@ -401,8 +401,8 @@ static int zx_i2s_probe(struct platform_device *pdev) writel_relaxed(0, zx_i2s->reg_base + ZX_I2S_FIFO_CTRL); platform_set_drvdata(pdev, zx_i2s); - ret = snd_soc_register_component(&pdev->dev, &zx_i2s_component, - &zx_i2s_dai, 1); + ret = devm_snd_soc_register_component(&pdev->dev, &zx_i2s_component, + &zx_i2s_dai, 1); if (ret) { dev_err(&pdev->dev, "Register DAI failed: %d\n", ret); return ret;