From: Viorel Suman <viorel.suman@nxp.com>
To: Timur Tabi <timur@kernel.org>,
Nicolin Chen <nicoleotsuka@gmail.com>,
Xiubo Li <Xiubo.Lee@gmail.com>,
Fabio Estevam <festevam@gmail.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
Takashi Iwai <tiwai@suse.com>, Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Julia Lawall <Julia.Lawall@lip6.fr>
Cc: "alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>,
Viorel Suman <viorel.suman@nxp.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Viorel Suman <viorel.suman@gmail.com>,
dl-linux-imx <linux-imx@nxp.com>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>
Subject: [PATCH 2/2] ASoC: imx-audmix: fix object reference leaks in probe
Date: Tue, 9 Apr 2019 08:35:35 +0000 [thread overview]
Message-ID: <1554798876-20653-3-git-send-email-viorel.suman@nxp.com> (raw)
In-Reply-To: <1554798876-20653-1-git-send-email-viorel.suman@nxp.com>
Release the reference to the underlying device taken
by of_find_device_by_node() call.
Signed-off-by: Viorel Suman <viorel.suman@nxp.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
next prev parent reply other threads:[~2019-04-09 8:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-09 8:35 [PATCH 0/2] ASoC: fsl: audmix: fix two issues Viorel Suman
2019-04-09 8:35 ` [PATCH 1/2] ASoC: fsl_audmix: remove "model" attribute Viorel Suman
2019-04-09 10:05 ` Daniel Baluta
2019-04-09 8:35 ` Viorel Suman [this message]
2019-04-09 10:08 ` [PATCH 2/2] ASoC: imx-audmix: fix object reference leaks in probe Daniel Baluta
2019-04-09 8:55 ` [PATCH 0/2] ASoC: fsl: audmix: fix two issues Viorel Suman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1554798876-20653-3-git-send-email-viorel.suman@nxp.com \
--to=viorel.suman@nxp.com \
--cc=Julia.Lawall@lip6.fr \
--cc=Xiubo.Lee@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=festevam@gmail.com \
--cc=kernel@pengutronix.de \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=nicoleotsuka@gmail.com \
--cc=perex@perex.cz \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=timur@kernel.org \
--cc=tiwai@suse.com \
--cc=viorel.suman@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).