Commit 95d3befb authored by Chuhong Yuan's avatar Chuhong Yuan Committed by Mark Brown

ASoC: amd: change clk_get() to devm_clk_get() and add missed checks

cz_da7219_init() does not check the return values of clk_get(),
while da7219_clk_enable() calls clk_set_rate() to dereference
the pointers.
Add checks to fix the problems.
Also, change clk_get() to devm_clk_get() to avoid data leak after
failures.

Fixes: bb24a31e ("ASoC: AMD: Configure wclk and bclk of master codec")
Signed-off-by: default avatarChuhong Yuan <hslester96@gmail.com>
Link: https://lore.kernel.org/r/20201204063610.513556-1-hslester96@gmail.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 0d024a8b
...@@ -73,8 +73,13 @@ static int cz_da7219_init(struct snd_soc_pcm_runtime *rtd) ...@@ -73,8 +73,13 @@ static int cz_da7219_init(struct snd_soc_pcm_runtime *rtd)
return ret; return ret;
} }
da7219_dai_wclk = clk_get(component->dev, "da7219-dai-wclk"); da7219_dai_wclk = devm_clk_get(component->dev, "da7219-dai-wclk");
da7219_dai_bclk = clk_get(component->dev, "da7219-dai-bclk"); if (IS_ERR(da7219_dai_wclk))
return PTR_ERR(da7219_dai_wclk);
da7219_dai_bclk = devm_clk_get(component->dev, "da7219-dai-bclk");
if (IS_ERR(da7219_dai_bclk))
return PTR_ERR(da7219_dai_bclk);
ret = snd_soc_card_jack_new(card, "Headset Jack", ret = snd_soc_card_jack_new(card, "Headset Jack",
SND_JACK_HEADSET | SND_JACK_LINEOUT | SND_JACK_HEADSET | SND_JACK_LINEOUT |
......
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