Skip to contentSkip to conversation

ASoC: amd: add missed checks for clk_get()

PATCH In review Chuhong Yuan 2 participants 2 messages Dec 3, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: amd: add missed checks for clk_get()

cz_da7219_init() does not check the return value of clk_get(), while da7219_clk_enable() calls clk_set_rate() to dereference the pointers.
Add checks to fix the problems.

Fixes bb24a31ed584 ("ASoC: AMD: Configure wclk and bclk of master codec")
---
 sound/soc/amd/acp-da7219-max98357a.c | 5 +++++
 1 file changed, 5 insertions(+)
sound/soc/amd/acp-da7219-max98357a.c +5 -0
index a7702e64ec51..d5185cd3106b 100644
@@ -74,7 +74,12 @@ static int cz_da7219_init(struct snd_soc_pcm_runtime *rtd)
 	}
 
 	da7219_dai_wclk = clk_get(component->dev, "da7219-dai-wclk");
+	if (IS_ERR(da7219_dai_wclk))
+		return PTR_ERR(da7219_dai_wclk);
+
 	da7219_dai_bclk = 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 |
Signature · 1 line
2.26.2
maintainer
#1 lore raw

sound/soc/amd/acp-da7219-max98357a.c static int cz_da7219_init(struct snd_soc_pcm_runtime *rtd) · line 82

Quoted 7 lines · Chuhong Yuan
sound/soc/amd/acp-da7219-max98357a.c +5 -0
 	da7219_dai_wclk = clk_get(component->dev, "da7219-dai-wclk");
+	if (IS_ERR(da7219_dai_wclk))
+		return PTR_ERR(da7219_dai_wclk);
+
 	da7219_dai_bclk = clk_get(component->dev, "da7219-dai-bclk");
+	if (IS_ERR(da7219_dai_bclk))
+		return PTR_ERR(da7219_dai_bclk);

This is also buggy - instead of ignoring the errors (which is an issue) we now leak the wclk if the bclk fails. Probably should convert to devm as well.