* [PATCH 1/2] ASoC: fsl_mqs: move of_node_put() to the correct location
@ 2023-04-03 15:26 Liliang Ye
2023-04-03 15:36 ` Dan Carpenter
2023-04-17 20:27 ` Mark Brown
0 siblings, 2 replies; 3+ messages in thread
From: Liliang Ye @ 2023-04-03 15:26 UTC (permalink / raw)
To: Shengjiu Wang, Xiubo Li, Fabio Estevam, Nicolin Chen,
Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
Dan Carpenter
Cc: hust-os-kernel-patches, Liliang Ye, alsa-devel, linuxppc-dev,
linux-kernel
of_node_put() should have been done directly after
mqs_priv->regmap = syscon_node_to_regmap(gpr_np);
otherwise it creates a reference leak on the success path.
To fix this, of_node_put() is moved to the correct location, and change
all the gotos to direct returns.
Fixes: a9d273671440 ("ASoC: fsl_mqs: Fix error handling in probe")
Signed-off-by: Liliang Ye <yll@hust.edu.cn>
Reviewed-by: Dan Carpenter <error27@gmail.com>
---
sound/soc/fsl/fsl_mqs.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/sound/soc/fsl/fsl_mqs.c b/sound/soc/fsl/fsl_mqs.c
index 4922e6795b73..32d20d351bbf 100644
--- a/sound/soc/fsl/fsl_mqs.c
+++ b/sound/soc/fsl/fsl_mqs.c
@@ -210,10 +210,10 @@ static int fsl_mqs_probe(struct platform_device *pdev)
}
mqs_priv->regmap = syscon_node_to_regmap(gpr_np);
+ of_node_put(gpr_np);
if (IS_ERR(mqs_priv->regmap)) {
dev_err(&pdev->dev, "failed to get gpr regmap\n");
- ret = PTR_ERR(mqs_priv->regmap);
- goto err_free_gpr_np;
+ return PTR_ERR(mqs_priv->regmap);
}
} else {
regs = devm_platform_ioremap_resource(pdev, 0);
@@ -242,8 +242,7 @@ static int fsl_mqs_probe(struct platform_device *pdev)
if (IS_ERR(mqs_priv->mclk)) {
dev_err(&pdev->dev, "failed to get the clock: %ld\n",
PTR_ERR(mqs_priv->mclk));
- ret = PTR_ERR(mqs_priv->mclk);
- goto err_free_gpr_np;
+ return PTR_ERR(mqs_priv->mclk);
}
dev_set_drvdata(&pdev->dev, mqs_priv);
@@ -252,13 +251,9 @@ static int fsl_mqs_probe(struct platform_device *pdev)
ret = devm_snd_soc_register_component(&pdev->dev, &soc_codec_fsl_mqs,
&fsl_mqs_dai, 1);
if (ret)
- goto err_free_gpr_np;
- return 0;
-
-err_free_gpr_np:
- of_node_put(gpr_np);
+ return ret;
- return ret;
+ return 0;
}
static int fsl_mqs_remove(struct platform_device *pdev)
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] ASoC: fsl_mqs: move of_node_put() to the correct location
2023-04-03 15:26 [PATCH 1/2] ASoC: fsl_mqs: move of_node_put() to the correct location Liliang Ye
@ 2023-04-03 15:36 ` Dan Carpenter
2023-04-17 20:27 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2023-04-03 15:36 UTC (permalink / raw)
To: Liliang Ye
Cc: Shengjiu Wang, Xiubo Li, Fabio Estevam, Nicolin Chen,
Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
hust-os-kernel-patches, alsa-devel, linuxppc-dev, linux-kernel
On Mon, Apr 03, 2023 at 11:26:47PM +0800, Liliang Ye wrote:
> of_node_put() should have been done directly after
> mqs_priv->regmap = syscon_node_to_regmap(gpr_np);
> otherwise it creates a reference leak on the success path.
>
> To fix this, of_node_put() is moved to the correct location, and change
> all the gotos to direct returns.
>
> Fixes: a9d273671440 ("ASoC: fsl_mqs: Fix error handling in probe")
> Signed-off-by: Liliang Ye <yll@hust.edu.cn>
> Reviewed-by: Dan Carpenter <error27@gmail.com>
> ---
These patches are from a university. I think this patch was based on
manual review rather than static analysis. They have not been tested
and this one affects the success path so that's always extra risky.
However I do believe the patch is correct and reviewed it before it was
sent publically.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] ASoC: fsl_mqs: move of_node_put() to the correct location
2023-04-03 15:26 [PATCH 1/2] ASoC: fsl_mqs: move of_node_put() to the correct location Liliang Ye
2023-04-03 15:36 ` Dan Carpenter
@ 2023-04-17 20:27 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2023-04-17 20:27 UTC (permalink / raw)
To: Shengjiu Wang, Xiubo Li, Fabio Estevam, Nicolin Chen,
Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Dan Carpenter,
Liliang Ye
Cc: hust-os-kernel-patches, alsa-devel, linuxppc-dev, linux-kernel
On Mon, 03 Apr 2023 23:26:47 +0800, Liliang Ye wrote:
> of_node_put() should have been done directly after
> mqs_priv->regmap = syscon_node_to_regmap(gpr_np);
> otherwise it creates a reference leak on the success path.
>
> To fix this, of_node_put() is moved to the correct location, and change
> all the gotos to direct returns.
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/2] ASoC: fsl_mqs: move of_node_put() to the correct location
commit: 1c34890273a020d61d6127ade3f68ed1cb21c16a
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-04-17 20:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-03 15:26 [PATCH 1/2] ASoC: fsl_mqs: move of_node_put() to the correct location Liliang Ye
2023-04-03 15:36 ` Dan Carpenter
2023-04-17 20:27 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®