From patchwork Mon Feb 2 04:53:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 5759231 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 EC25C9F380 for ; Mon, 2 Feb 2015 04:55:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 11CB520266 for ; Mon, 2 Feb 2015 04:55:11 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id CDB65201B9 for ; Mon, 2 Feb 2015 04:55:09 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id E93A82604CC; Mon, 2 Feb 2015 05:55:08 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id B1D6F260513; Mon, 2 Feb 2015 05:54:31 +0100 (CET) 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 5782D26050C; Mon, 2 Feb 2015 05:54:30 +0100 (CET) Received: from relmlie2.idc.renesas.com (relmlor3.renesas.com [210.160.252.173]) by alsa0.perex.cz (Postfix) with ESMTP id D548C26047E for ; Mon, 2 Feb 2015 05:53:57 +0100 (CET) Received: from unknown (HELO relmlir4.idc.renesas.com) ([10.200.68.154]) by relmlie2.idc.renesas.com with ESMTP; 02 Feb 2015 13:53:56 +0900 Received: from relmlac4.idc.renesas.com (relmlac4.idc.renesas.com [10.200.69.24]) by relmlir4.idc.renesas.com (Postfix) with ESMTP id 6FEB2445EF; Mon, 2 Feb 2015 13:53:56 +0900 (JST) Received: by relmlac4.idc.renesas.com (Postfix, from userid 0) id 538BB480A4; Mon, 2 Feb 2015 13:53:56 +0900 (JST) Received: from relmlac4.idc.renesas.com (localhost [127.0.0.1]) by relmlac4.idc.renesas.com (Postfix) with ESMTP id 4D536480A3; Mon, 2 Feb 2015 13:53:56 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac4.idc.renesas.com with ESMTP id PAD26210; Mon, 2 Feb 2015 13:53:56 +0900 X-IronPort-AV: E=Sophos;i="5.09,504,1418050800"; d="scan'208";a="178927381" Received: from mail-sg1lp0089.outbound.protection.outlook.com (HELO APAC01-SG1-obe.outbound.protection.outlook.com) ([207.46.51.89]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA; 02 Feb 2015 13:53:55 +0900 Received: from remon.renesas.com (211.11.155.132) by SINPR06MB170.apcprd06.prod.outlook.com (10.242.57.16) with Microsoft SMTP Server (TLS) id 15.1.75.20; Mon, 2 Feb 2015 04:53:53 +0000 Message-ID: <87egq8gbfk.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto , Kuninori Morimoto User-Agent: Wanderlust/2.14.0 Emacs/23.3 Mule/6.0 MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") To: Mark Brown In-Reply-To: <87h9v4gbhg.wl%kuninori.morimoto.gx@renesas.com> References: <87h9v4gbhg.wl%kuninori.morimoto.gx@renesas.com> Date: Mon, 2 Feb 2015 04:53:53 +0000 X-Originating-IP: [211.11.155.132] X-ClientProxiedBy: HKXPR03CA0062.apcprd03.prod.outlook.com (10.141.129.52) To SINPR06MB170.apcprd06.prod.outlook.com (10.242.57.16) Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none; X-Microsoft-Antispam: UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:SINPR06MB170; X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004); SRVR:SINPR06MB170; X-Forefront-PRVS: 0475418F50 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(47776003)(110136001)(86362001)(46406003)(53416004)(50986999)(76176999)(54356999)(77096005)(19580395003)(92566002)(40100003)(229853001)(83506001)(2950100001)(19580405001)(50466002)(33646002)(23726002)(46102003)(77156002)(62966003)(122386002)(575784001)(42186005)(87976001)(66066001)(36756003)(21314002); DIR:OUT; SFP:1102; SCL:1; SRVR:SINPR06MB170; H:remon.renesas.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:;SRVR:SINPR06MB170; X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2015 04:53:53.3310 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SINPR06MB170 Cc: Linux-ALSA , Simon , Liam Girdwood Subject: [alsa-devel] [PATCH 1/2] ASoC: rsnd: call missing snd_ctl_remove() 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: Kuninori Morimoto Current Renesas R-Car sound driver is using snd_ctl_xxx() functions, but it didn't call snd_ctl free_one() / snd_ctl_remove(). This patch call these functions. Reported-by: Nguyen Viet Dung Reported-by: Bui Duc Phuc Reported-by: Cao Minh Hiep Signed-off-by: Kuninori Morimoto --- sound/soc/sh/rcar/core.c | 11 ++++++++++- sound/soc/sh/rcar/dvc.c | 15 +++++++++++++++ sound/soc/sh/rcar/rsnd.h | 5 +++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index f0bb137..6fb38b8 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -1046,14 +1046,23 @@ static int __rsnd_kctrl_new(struct rsnd_mod *mod, return -ENOMEM; ret = snd_ctl_add(card, kctrl); - if (ret < 0) + if (ret < 0) { + snd_ctl_free_one(kctrl); return ret; + } cfg->update = update; + cfg->card = card; + cfg->kctrl = kctrl; return 0; } +void _rsnd_kctrl_remove(struct rsnd_kctrl_cfg *cfg) +{ + snd_ctl_remove(cfg->card, cfg->kctrl); +} + int rsnd_kctrl_new_m(struct rsnd_mod *mod, struct snd_soc_pcm_runtime *rtd, const unsigned char *name, diff --git a/sound/soc/sh/rcar/dvc.c b/sound/soc/sh/rcar/dvc.c index 38a5f33..d7f9ed9 100644 --- a/sound/soc/sh/rcar/dvc.c +++ b/sound/soc/sh/rcar/dvc.c @@ -127,6 +127,20 @@ static int rsnd_dvc_probe_gen2(struct rsnd_mod *mod, return 0; } +static int rsnd_dvc_remove_gen2(struct rsnd_mod *mod, + struct rsnd_priv *priv) +{ + struct rsnd_dvc *dvc = rsnd_mod_to_dvc(mod); + + rsnd_kctrl_remove(dvc->volume); + rsnd_kctrl_remove(dvc->mute); + rsnd_kctrl_remove(dvc->ren); + rsnd_kctrl_remove(dvc->rup); + rsnd_kctrl_remove(dvc->rdown); + + return 0; +} + static int rsnd_dvc_init(struct rsnd_mod *dvc_mod, struct rsnd_priv *priv) { @@ -258,6 +272,7 @@ static int rsnd_dvc_pcm_new(struct rsnd_mod *mod, static struct rsnd_mod_ops rsnd_dvc_ops = { .name = DVC_NAME, .probe = rsnd_dvc_probe_gen2, + .remove = rsnd_dvc_remove_gen2, .init = rsnd_dvc_init, .quit = rsnd_dvc_quit, .start = rsnd_dvc_start, diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index b57d8ac..e7914bd 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h @@ -436,6 +436,8 @@ struct rsnd_kctrl_cfg { u32 *val; const char * const *texts; void (*update)(struct rsnd_mod *mod); + struct snd_card *card; + struct snd_kcontrol *kctrl; }; #define RSND_DVC_CHANNELS 2 @@ -449,6 +451,9 @@ struct rsnd_kctrl_cfg_s { u32 val; }; +void _rsnd_kctrl_remove(struct rsnd_kctrl_cfg *cfg); +#define rsnd_kctrl_remove(_cfg) _rsnd_kctrl_remove(&((_cfg).cfg)) + int rsnd_kctrl_new_m(struct rsnd_mod *mod, struct snd_soc_pcm_runtime *rtd, const unsigned char *name,