Commit 03990fd5 authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Mark Brown

ASoC: ti: omap-mcbsp: Fix an error handling path in 'asoc_mcbsp_probe()'

If an error occurs after the call to 'omap_mcbsp_init()', the reference to
'mcbsp->fclk' must be decremented, as already done in the remove function.

This can be achieved easily by using the devm_ variant of 'clk_get()'
when the reference is taken in 'omap_mcbsp_init()'

This fixes the leak in the probe and has the side effect to simplify both
the error handling path of 'omap_mcbsp_init()' and the remove function.
Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: default avatarPeter Ujfalusi <peter.ujflausi@ti.com>
Link: https://lore.kernel.org/r/20200512134325.252073-1-christophe.jaillet@wanadoo.frSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent cc2d025a
...@@ -686,7 +686,7 @@ static int omap_mcbsp_init(struct platform_device *pdev) ...@@ -686,7 +686,7 @@ static int omap_mcbsp_init(struct platform_device *pdev)
mcbsp->dma_data[1].addr = omap_mcbsp_dma_reg_params(mcbsp, mcbsp->dma_data[1].addr = omap_mcbsp_dma_reg_params(mcbsp,
SNDRV_PCM_STREAM_CAPTURE); SNDRV_PCM_STREAM_CAPTURE);
mcbsp->fclk = clk_get(&pdev->dev, "fck"); mcbsp->fclk = devm_clk_get(&pdev->dev, "fck");
if (IS_ERR(mcbsp->fclk)) { if (IS_ERR(mcbsp->fclk)) {
ret = PTR_ERR(mcbsp->fclk); ret = PTR_ERR(mcbsp->fclk);
dev_err(mcbsp->dev, "unable to get fck: %d\n", ret); dev_err(mcbsp->dev, "unable to get fck: %d\n", ret);
...@@ -711,7 +711,7 @@ static int omap_mcbsp_init(struct platform_device *pdev) ...@@ -711,7 +711,7 @@ static int omap_mcbsp_init(struct platform_device *pdev)
if (ret) { if (ret) {
dev_err(mcbsp->dev, dev_err(mcbsp->dev,
"Unable to create additional controls\n"); "Unable to create additional controls\n");
goto err_thres; return ret;
} }
} }
...@@ -724,8 +724,6 @@ static int omap_mcbsp_init(struct platform_device *pdev) ...@@ -724,8 +724,6 @@ static int omap_mcbsp_init(struct platform_device *pdev)
err_st: err_st:
if (mcbsp->pdata->buffer_size) if (mcbsp->pdata->buffer_size)
sysfs_remove_group(&mcbsp->dev->kobj, &additional_attr_group); sysfs_remove_group(&mcbsp->dev->kobj, &additional_attr_group);
err_thres:
clk_put(mcbsp->fclk);
return ret; return ret;
} }
...@@ -1442,8 +1440,6 @@ static int asoc_mcbsp_remove(struct platform_device *pdev) ...@@ -1442,8 +1440,6 @@ static int asoc_mcbsp_remove(struct platform_device *pdev)
omap_mcbsp_st_cleanup(pdev); omap_mcbsp_st_cleanup(pdev);
clk_put(mcbsp->fclk);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment