From patchwork Tue Apr 9 08:35:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viorel Suman X-Patchwork-Id: 10890825 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 E0819139A for ; Tue, 9 Apr 2019 09:16:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF2E328862 for ; Tue, 9 Apr 2019 09:16:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B11772889B; Tue, 9 Apr 2019 09:16:54 +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,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A856528891 for ; Tue, 9 Apr 2019 09:16:53 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 9F7F79EB; Tue, 9 Apr 2019 10:37:24 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 9F7F79EB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1554799094; bh=eivAh2+RwpBUASw2HHTHjlIyeGtvPiTxIZhFBIjKXTo=; h=From:To:Date:References:In-Reply-To:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=OgFQJ57E+8yYag7RXbPnOYYXTw50OZcAmck994it1bOiPHYJKT3n6E3JEXOiF9+TI dJET/aMw9nJE+k1XPtVaoxVSqKazdTK5+RC+YPOMZi3V1369PfRxktvnhFWMPneCGN IBDSquHUn/rRTj2AHcHG4ZIcv3APqpTRsppBJAzA= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id D94ADF8971B; Tue, 9 Apr 2019 10:35:48 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 8A0AFF896F7; Tue, 9 Apr 2019 10:35:43 +0200 (CEST) Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70055.outbound.protection.outlook.com [40.107.7.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 2E0B7F80C17 for ; Tue, 9 Apr 2019 10:35:39 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 2E0B7F80C17 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="s6Zl0Dk4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZkFS7fOKXY4eaBsvRVjQ21ozJNA3OcWuRPR29jAgAek=; b=s6Zl0Dk4SVWxtKS8ffhG9CEATj0dMzwXIWJoV1mKkEZo640uyei2Of0eHaioZoKMUA56ENBA4CKyG6hXeMVVHtL/KPdZ+uxOBLQLRnTp63wyPdAEZJr8p2a4y0z35UIV/SJJQZHYhmT3Yr0dlRNM+omRsJC/qflgxdim2y9KmPg= Received: from VI1PR04MB4704.eurprd04.prod.outlook.com (20.177.48.157) by VI1PR04MB3983.eurprd04.prod.outlook.com (10.171.182.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1771.16; Tue, 9 Apr 2019 08:35:35 +0000 Received: from VI1PR04MB4704.eurprd04.prod.outlook.com ([fe80::2594:3cf0:20a2:8888]) by VI1PR04MB4704.eurprd04.prod.outlook.com ([fe80::2594:3cf0:20a2:8888%3]) with mapi id 15.20.1792.009; Tue, 9 Apr 2019 08:35:35 +0000 From: Viorel Suman To: Timur Tabi , Nicolin Chen , Xiubo Li , Fabio Estevam , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Shawn Guo , Sascha Hauer , Julia Lawall Thread-Topic: [PATCH 2/2] ASoC: imx-audmix: fix object reference leaks in probe Thread-Index: AQHU7q8zoMDMeUy2P0Ct5Mpi9gwjqg== Date: Tue, 9 Apr 2019 08:35:35 +0000 Message-ID: <1554798876-20653-3-git-send-email-viorel.suman@nxp.com> References: <1554798876-20653-1-git-send-email-viorel.suman@nxp.com> In-Reply-To: <1554798876-20653-1-git-send-email-viorel.suman@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VE1PR03CA0004.eurprd03.prod.outlook.com (2603:10a6:802:a0::16) To VI1PR04MB4704.eurprd04.prod.outlook.com (2603:10a6:803:52::29) authentication-results: spf=none (sender IP is ) smtp.mailfrom=viorel.suman@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.7.4 x-originating-ip: [212.146.100.6] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 4cf04229-6667-4b5f-24d4-08d6bcc655fa x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600139)(711020)(4605104)(4618075)(2017052603328)(7193020); SRVR:VI1PR04MB3983; x-ms-traffictypediagnostic: VI1PR04MB3983: x-microsoft-antispam-prvs: x-forefront-prvs: 000227DA0C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(376002)(366004)(39860400002)(396003)(136003)(189003)(199004)(305945005)(5660300002)(106356001)(4326008)(68736007)(105586002)(52116002)(14454004)(97736004)(186003)(36756003)(110136005)(54906003)(53936002)(81156014)(7736002)(8676002)(81166006)(25786009)(6486002)(50226002)(6512007)(7416002)(6436002)(8936002)(99286004)(2616005)(66066001)(11346002)(3846002)(6116002)(256004)(446003)(316002)(476003)(86362001)(2906002)(71190400001)(71200400001)(386003)(6506007)(486006)(478600001)(102836004)(76176011)(26005)(44832011)(921003)(1121003); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR04MB3983; H:VI1PR04MB4704.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: qits80QiWfjSpVuTC3sU4QBS6qrmvpG0fLKd4Hig4iMmY7NO0/0jbYdA7iWHtp2nJXbGYozP+UJWcafdx+KpdLnt0+pFB0a0NEGPhavWzINaUZmNdFO7RLOOy4pbXX6h3ssaECJVfNuX8Rr++RX6GEdnZQTWwqueyb52J92Prz+OZrUeuG6Lpq2xDpA3UMaaBCvMEmxADitfF4EGaa/VjBKBlXI2fDOXx6ELglBjx7443mwjIUBbG1ql30BfF/qJREtax85PXeDh7BuXuycUUnRhlz4pPP5gdUpoiV85Pj5sRtdN1JfNtK41Ofe1NOyV1TVyuLms9U/5Cnf24NHs18+1+9xZGJjDqYh8mdJCuuX7JLp+r1gnQ2IZ89e6kwhftuxiTcAwGzQBkG32J+i5n//UwcwXottYnZMGn3AyAlQ= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4cf04229-6667-4b5f-24d4-08d6bcc655fa X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2019 08:35:35.4839 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB3983 Cc: "alsa-devel@alsa-project.org" , Viorel Suman , "linux-kernel@vger.kernel.org" , Viorel Suman , dl-linux-imx , Pengutronix Kernel Team , "linuxppc-dev@lists.ozlabs.org" , "linux-arm-kernel@lists.infradead.org" Subject: [alsa-devel] [PATCH 2/2] ASoC: imx-audmix: fix object reference leaks in probe X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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" X-Virus-Scanned: ClamAV using ClamSMTP Release the reference to the underlying device taken by of_find_device_by_node() call. Signed-off-by: Viorel Suman --- sound/soc/fsl/imx-audmix.c | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/sound/soc/fsl/imx-audmix.c b/sound/soc/fsl/imx-audmix.c index 7983bd3..7c24095 100644 --- a/sound/soc/fsl/imx-audmix.c +++ b/sound/soc/fsl/imx-audmix.c @@ -20,10 +20,7 @@ #include "fsl_audmix.h" struct imx_audmix { - struct platform_device *pdev; struct snd_soc_card card; - struct platform_device *audmix_pdev; - struct platform_device *out_pdev; struct clk *cpu_mclk; int num_dai; struct snd_soc_dai_link *dai; @@ -144,7 +141,7 @@ static struct snd_soc_ops imx_audmix_be_ops = { static int imx_audmix_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; - struct device_node *audmix_np = NULL, *out_cpu_np = NULL; + struct device_node *audmix_np = NULL; struct platform_device *audmix_pdev = NULL; struct platform_device *cpu_pdev; struct of_phandle_args args; @@ -171,6 +168,7 @@ static int imx_audmix_probe(struct platform_device *pdev) np->full_name); return -EINVAL; } + put_device(&audmix_pdev->dev); num_dai = of_count_phandle_with_args(audmix_np, "dais", NULL); if (num_dai != FSL_AUDMIX_MAX_DAIS) { @@ -216,6 +214,7 @@ static int imx_audmix_probe(struct platform_device *pdev) dev_err(&pdev->dev, "failed to find SAI platform device\n"); return -EINVAL; } + put_device(&cpu_pdev->dev); dai_name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s%s", fe_name_pref, args.np->full_name + 1); @@ -223,7 +222,14 @@ static int imx_audmix_probe(struct platform_device *pdev) dev_info(pdev->dev.parent, "DAI FE name:%s\n", dai_name); if (i == 0) { - out_cpu_np = args.np; + priv->cpu_mclk = devm_clk_get(&cpu_pdev->dev, "mclk1"); + if (IS_ERR(priv->cpu_mclk)) { + ret = PTR_ERR(priv->cpu_mclk); + dev_err(&cpu_pdev->dev, + "failed to get DAI mclk1: %d\n", ret); + return -EINVAL; + } + capture_dai_name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s %s", dai_name, "CPU-Capture"); @@ -275,21 +281,6 @@ static int imx_audmix_probe(struct platform_device *pdev) priv->dapm_routes[2 * num_dai + i].sink = capture_dai_name; } - cpu_pdev = of_find_device_by_node(out_cpu_np); - if (!cpu_pdev) { - dev_err(&pdev->dev, "failed to find SAI platform device\n"); - return -EINVAL; - } - priv->cpu_mclk = devm_clk_get(&cpu_pdev->dev, "mclk1"); - if (IS_ERR(priv->cpu_mclk)) { - ret = PTR_ERR(priv->cpu_mclk); - dev_err(&cpu_pdev->dev, "failed to get DAI mclk1: %d\n", ret); - return -EINVAL; - } - - priv->audmix_pdev = audmix_pdev; - priv->out_pdev = cpu_pdev; - priv->card.dai_link = priv->dai; priv->card.num_links = priv->num_dai; priv->card.codec_conf = priv->dai_conf;