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: a9d2736714
("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>
This commit is contained in:
parent
97c236e2d4
commit
1c34890273
@ -210,10 +210,10 @@ static int fsl_mqs_probe(struct platform_device *pdev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
mqs_priv->regmap = syscon_node_to_regmap(gpr_np);
|
mqs_priv->regmap = syscon_node_to_regmap(gpr_np);
|
||||||
|
of_node_put(gpr_np);
|
||||||
if (IS_ERR(mqs_priv->regmap)) {
|
if (IS_ERR(mqs_priv->regmap)) {
|
||||||
dev_err(&pdev->dev, "failed to get gpr regmap\n");
|
dev_err(&pdev->dev, "failed to get gpr regmap\n");
|
||||||
ret = PTR_ERR(mqs_priv->regmap);
|
return PTR_ERR(mqs_priv->regmap);
|
||||||
goto err_free_gpr_np;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
regs = devm_platform_ioremap_resource(pdev, 0);
|
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)) {
|
if (IS_ERR(mqs_priv->mclk)) {
|
||||||
dev_err(&pdev->dev, "failed to get the clock: %ld\n",
|
dev_err(&pdev->dev, "failed to get the clock: %ld\n",
|
||||||
PTR_ERR(mqs_priv->mclk));
|
PTR_ERR(mqs_priv->mclk));
|
||||||
ret = PTR_ERR(mqs_priv->mclk);
|
return PTR_ERR(mqs_priv->mclk);
|
||||||
goto err_free_gpr_np;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dev_set_drvdata(&pdev->dev, mqs_priv);
|
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,
|
ret = devm_snd_soc_register_component(&pdev->dev, &soc_codec_fsl_mqs,
|
||||||
&fsl_mqs_dai, 1);
|
&fsl_mqs_dai, 1);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err_free_gpr_np;
|
return ret;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_free_gpr_np:
|
|
||||||
of_node_put(gpr_np);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fsl_mqs_remove(struct platform_device *pdev)
|
static void fsl_mqs_remove(struct platform_device *pdev)
|
||||||
|
Loading…
Reference in New Issue
Block a user