Skip to content

Commit 1c34890

Browse files
LelandKamibroonie
authored andcommitted
ASoC: fsl_mqs: move of_node_put() to the correct location
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: a9d2736 ("ASoC: fsl_mqs: Fix error handling in probe") Signed-off-by: Liliang Ye <yll@hust.edu.cn> Reviewed-by: Dan Carpenter <error27@gmail.com> Link: https://lore.kernel.org/r/20230403152647.17638-1-yll@hust.edu.cn Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 97c236e commit 1c34890

1 file changed

Lines changed: 5 additions & 10 deletions

File tree

sound/soc/fsl/fsl_mqs.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,10 @@ static int fsl_mqs_probe(struct platform_device *pdev)
210210
}
211211

212212
mqs_priv->regmap = syscon_node_to_regmap(gpr_np);
213+
of_node_put(gpr_np);
213214
if (IS_ERR(mqs_priv->regmap)) {
214215
dev_err(&pdev->dev, "failed to get gpr regmap\n");
215-
ret = PTR_ERR(mqs_priv->regmap);
216-
goto err_free_gpr_np;
216+
return PTR_ERR(mqs_priv->regmap);
217217
}
218218
} else {
219219
regs = devm_platform_ioremap_resource(pdev, 0);
@@ -242,8 +242,7 @@ static int fsl_mqs_probe(struct platform_device *pdev)
242242
if (IS_ERR(mqs_priv->mclk)) {
243243
dev_err(&pdev->dev, "failed to get the clock: %ld\n",
244244
PTR_ERR(mqs_priv->mclk));
245-
ret = PTR_ERR(mqs_priv->mclk);
246-
goto err_free_gpr_np;
245+
return PTR_ERR(mqs_priv->mclk);
247246
}
248247

249248
dev_set_drvdata(&pdev->dev, mqs_priv);
@@ -252,13 +251,9 @@ static int fsl_mqs_probe(struct platform_device *pdev)
252251
ret = devm_snd_soc_register_component(&pdev->dev, &soc_codec_fsl_mqs,
253252
&fsl_mqs_dai, 1);
254253
if (ret)
255-
goto err_free_gpr_np;
256-
return 0;
257-
258-
err_free_gpr_np:
259-
of_node_put(gpr_np);
254+
return ret;
260255

261-
return ret;
256+
return 0;
262257
}
263258

264259
static void fsl_mqs_remove(struct platform_device *pdev)

0 commit comments

Comments
 (0)