Skip to content

Commit

Permalink
ASoC: amd: change clk_get() to devm_clk_get() and add missed checks
Browse files Browse the repository at this point in the history
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: bb24a31 ("ASoC: AMD: Configure wclk and bclk of master codec")
Signed-off-by: Chuhong Yuan <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>
  • Loading branch information
WillLester authored and broonie committed Dec 8, 2020
1 parent 0d024a8 commit 95d3bef
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions sound/soc/amd/acp-da7219-max98357a.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,13 @@ static int cz_da7219_init(struct snd_soc_pcm_runtime *rtd)
return ret;
}

da7219_dai_wclk = clk_get(component->dev, "da7219-dai-wclk");
da7219_dai_bclk = clk_get(component->dev, "da7219-dai-bclk");
da7219_dai_wclk = devm_clk_get(component->dev, "da7219-dai-wclk");
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",
SND_JACK_HEADSET | SND_JACK_LINEOUT |
Expand Down

0 comments on commit 95d3bef

Please sign in to comment.