ASoC: rockchip: disable clock on error
Disable the clocks in rk_spdif_probe when an error occurs after one
of the clocks has been enabled previously.
Found by Linux Driver Verification project (linuxtesting.org).
Fixes: f874b80e15
ASoC: rockchip: Add rockchip SPDIF transceiver driver
Signed-off-by: Stefan Potyra <Stefan.Potyra@elektrobit.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
4fbd8d194f
commit
c7b92172a6
|
@ -322,26 +322,30 @@ static int rk_spdif_probe(struct platform_device *pdev)
|
|||
spdif->mclk = devm_clk_get(&pdev->dev, "mclk");
|
||||
if (IS_ERR(spdif->mclk)) {
|
||||
dev_err(&pdev->dev, "Can't retrieve rk_spdif master clock\n");
|
||||
return PTR_ERR(spdif->mclk);
|
||||
ret = PTR_ERR(spdif->mclk);
|
||||
goto err_disable_hclk;
|
||||
}
|
||||
|
||||
ret = clk_prepare_enable(spdif->mclk);
|
||||
if (ret) {
|
||||
dev_err(spdif->dev, "clock enable failed %d\n", ret);
|
||||
return ret;
|
||||
goto err_disable_clocks;
|
||||
}
|
||||
|
||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
regs = devm_ioremap_resource(&pdev->dev, res);
|
||||
if (IS_ERR(regs))
|
||||
return PTR_ERR(regs);
|
||||
if (IS_ERR(regs)) {
|
||||
ret = PTR_ERR(regs);
|
||||
goto err_disable_clocks;
|
||||
}
|
||||
|
||||
spdif->regmap = devm_regmap_init_mmio_clk(&pdev->dev, "hclk", regs,
|
||||
&rk_spdif_regmap_config);
|
||||
if (IS_ERR(spdif->regmap)) {
|
||||
dev_err(&pdev->dev,
|
||||
"Failed to initialise managed register map\n");
|
||||
return PTR_ERR(spdif->regmap);
|
||||
ret = PTR_ERR(spdif->regmap);
|
||||
goto err_disable_clocks;
|
||||
}
|
||||
|
||||
spdif->playback_dma_data.addr = res->start + SPDIF_SMPDR;
|
||||
|
@ -373,6 +377,10 @@ static int rk_spdif_probe(struct platform_device *pdev)
|
|||
|
||||
err_pm_runtime:
|
||||
pm_runtime_disable(&pdev->dev);
|
||||
err_disable_clocks:
|
||||
clk_disable_unprepare(spdif->mclk);
|
||||
err_disable_hclk:
|
||||
clk_disable_unprepare(spdif->hclk);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue