linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] ASoC: amd: change clk_get() to devm_clk_get() and add missed checks
@ 2020-12-04  6:36 Chuhong Yuan
  2020-12-08 17:09 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Chuhong Yuan @ 2020-12-04  6:36 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 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: bb24a31ed584 ("ASoC: AMD: Configure wclk and bclk of master codec")
Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
---
Changes in v2:
  - Replace clk_get() with devm_clk_get() to prevent data leak.

 sound/soc/amd/acp-da7219-max98357a.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

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


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

* Re: [PATCH v2] ASoC: amd: change clk_get() to devm_clk_get() and add missed checks
  2020-12-04  6:36 [PATCH v2] ASoC: amd: change clk_get() to devm_clk_get() and add missed checks Chuhong Yuan
@ 2020-12-08 17:09 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2020-12-08 17:09 UTC (permalink / raw)
  To: Chuhong Yuan
  Cc: linux-kernel, Pierre-Louis Bossart, Agrawal Akshu, Takashi Iwai,
	Kuninori Morimoto, alsa-devel, Liam Girdwood

On Fri, 4 Dec 2020 14:36:10 +0800, Chuhong Yuan wrote:
> 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.

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: amd: change clk_get() to devm_clk_get() and add missed checks
      commit: 95d3befbc5e1ee39fc8a78713924cf7ed2b3cabe

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

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

end of thread, other threads:[~2020-12-08 17:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-04  6:36 [PATCH v2] ASoC: amd: change clk_get() to devm_clk_get() and add missed checks Chuhong Yuan
2020-12-08 17:09 ` 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).