linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ASoC: amd: add missed checks for clk_get()
@ 2020-12-03 14:31 Chuhong Yuan
  2020-12-03 14:43 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Chuhong Yuan @ 2020-12-03 14:31 UTC (permalink / raw)
  Cc: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Kuninori Morimoto, Pierre-Louis Bossart, Agrawal Akshu,
	alsa-devel, linux-kernel, Chuhong Yuan

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")
Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
---
 sound/soc/amd/acp-da7219-max98357a.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/sound/soc/amd/acp-da7219-max98357a.c b/sound/soc/amd/acp-da7219-max98357a.c
index a7702e64ec51..d5185cd3106b 100644
--- a/sound/soc/amd/acp-da7219-max98357a.c
+++ b/sound/soc/amd/acp-da7219-max98357a.c
@@ -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 |
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ASoC: amd: add missed checks for clk_get()
  2020-12-03 14:31 [PATCH] ASoC: amd: add missed checks for clk_get() Chuhong Yuan
@ 2020-12-03 14:43 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2020-12-03 14:43 UTC (permalink / raw)
  To: Chuhong Yuan
  Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Kuninori Morimoto,
	Pierre-Louis Bossart, Agrawal Akshu, alsa-devel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 496 bytes --]

On Thu, Dec 03, 2020 at 10:31:16PM +0800, Chuhong Yuan wrote:

>  	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.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-12-03 14:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-03 14:31 [PATCH] ASoC: amd: add missed checks for clk_get() Chuhong Yuan
2020-12-03 14:43 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).