[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1554798876-20653-3-git-send-email-viorel.suman@nxp.com>
Date: Tue, 9 Apr 2019 08:35:35 +0000
From: Viorel Suman <viorel.suman@....com>
To: Timur Tabi <timur@...nel.org>,
Nicolin Chen <nicoleotsuka@...il.com>,
Xiubo Li <Xiubo.Lee@...il.com>,
Fabio Estevam <festevam@...il.com>,
Liam Girdwood <lgirdwood@...il.com>,
Mark Brown <broonie@...nel.org>,
Jaroslav Kysela <perex@...ex.cz>,
Takashi Iwai <tiwai@...e.com>, Shawn Guo <shawnguo@...nel.org>,
Sascha Hauer <s.hauer@...gutronix.de>,
Julia Lawall <Julia.Lawall@...6.fr>
CC: Viorel Suman <viorel.suman@....com>,
Viorel Suman <viorel.suman@...il.com>,
Pengutronix Kernel Team <kernel@...gutronix.de>,
dl-linux-imx <linux-imx@....com>,
"alsa-devel@...a-project.org" <alsa-devel@...a-project.org>,
"linuxppc-dev@...ts.ozlabs.org" <linuxppc-dev@...ts.ozlabs.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-arm-kernel@...ts.infradead.org"
<linux-arm-kernel@...ts.infradead.org>
Subject: [PATCH 2/2] ASoC: imx-audmix: fix object reference leaks in probe
Release the reference to the underlying device taken
by of_find_device_by_node() call.
Signed-off-by: Viorel Suman <viorel.suman@....com>
---
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;
--
2.7.4
Powered by blists - more mailing lists