linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ASoC: jz4740-i2s: add missed checks for clk_get()
@ 2020-12-03 14:42 Chuhong Yuan
  2020-12-03 16:38 ` Paul Cercueil
  2020-12-04 23:30 ` Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Chuhong Yuan @ 2020-12-03 14:42 UTC (permalink / raw)
  Cc: Paul Cercueil, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, Lars-Peter Clausen, alsa-devel, linux-kernel,
	Chuhong Yuan

jz4740_i2s_set_sysclk() does not check the return values of clk_get(),
while the file dereferences the pointers in clk_put().
Add the missed checks to fix it.

Fixes: 11bd3dd1b7c2 ("ASoC: Add JZ4740 ASoC support")
Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
---
 sound/soc/jz4740/jz4740-i2s.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sound/soc/jz4740/jz4740-i2s.c b/sound/soc/jz4740/jz4740-i2s.c
index c7bd20104b20..0793e284d0e7 100644
--- a/sound/soc/jz4740/jz4740-i2s.c
+++ b/sound/soc/jz4740/jz4740-i2s.c
@@ -312,10 +312,14 @@ static int jz4740_i2s_set_sysclk(struct snd_soc_dai *dai, int clk_id,
 	switch (clk_id) {
 	case JZ4740_I2S_CLKSRC_EXT:
 		parent = clk_get(NULL, "ext");
+		if (IS_ERR(parent))
+			return PTR_ERR(parent);
 		clk_set_parent(i2s->clk_i2s, parent);
 		break;
 	case JZ4740_I2S_CLKSRC_PLL:
 		parent = clk_get(NULL, "pll half");
+		if (IS_ERR(parent))
+			return PTR_ERR(parent);
 		clk_set_parent(i2s->clk_i2s, parent);
 		ret = clk_set_rate(i2s->clk_i2s, freq);
 		break;
-- 
2.26.2


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

* Re: [PATCH] ASoC: jz4740-i2s: add missed checks for clk_get()
  2020-12-03 14:42 [PATCH] ASoC: jz4740-i2s: add missed checks for clk_get() Chuhong Yuan
@ 2020-12-03 16:38 ` Paul Cercueil
  2020-12-04 23:30 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Paul Cercueil @ 2020-12-03 16:38 UTC (permalink / raw)
  To: Chuhong Yuan
  Cc: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Lars-Peter Clausen, alsa-devel, linux-kernel

Hi,

Le jeu. 3 déc. 2020 à 22:42, Chuhong Yuan <hslester96@gmail.com> a 
écrit :
> jz4740_i2s_set_sysclk() does not check the return values of clk_get(),
> while the file dereferences the pointers in clk_put().
> Add the missed checks to fix it.
> 
> Fixes: 11bd3dd1b7c2 ("ASoC: Add JZ4740 ASoC support")
> Signed-off-by: Chuhong Yuan <hslester96@gmail.com>

Acked-by: Paul Cercueil <paul@crapouillou.net>

Cheers,
-Paul

> ---
>  sound/soc/jz4740/jz4740-i2s.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/sound/soc/jz4740/jz4740-i2s.c 
> b/sound/soc/jz4740/jz4740-i2s.c
> index c7bd20104b20..0793e284d0e7 100644
> --- a/sound/soc/jz4740/jz4740-i2s.c
> +++ b/sound/soc/jz4740/jz4740-i2s.c
> @@ -312,10 +312,14 @@ static int jz4740_i2s_set_sysclk(struct 
> snd_soc_dai *dai, int clk_id,
>  	switch (clk_id) {
>  	case JZ4740_I2S_CLKSRC_EXT:
>  		parent = clk_get(NULL, "ext");
> +		if (IS_ERR(parent))
> +			return PTR_ERR(parent);
>  		clk_set_parent(i2s->clk_i2s, parent);
>  		break;
>  	case JZ4740_I2S_CLKSRC_PLL:
>  		parent = clk_get(NULL, "pll half");
> +		if (IS_ERR(parent))
> +			return PTR_ERR(parent);
>  		clk_set_parent(i2s->clk_i2s, parent);
>  		ret = clk_set_rate(i2s->clk_i2s, freq);
>  		break;
> --
> 2.26.2
> 



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

* Re: [PATCH] ASoC: jz4740-i2s: add missed checks for clk_get()
  2020-12-03 14:42 [PATCH] ASoC: jz4740-i2s: add missed checks for clk_get() Chuhong Yuan
  2020-12-03 16:38 ` Paul Cercueil
@ 2020-12-04 23:30 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2020-12-04 23:30 UTC (permalink / raw)
  To: Chuhong Yuan
  Cc: Lars-Peter Clausen, linux-kernel, alsa-devel, Paul Cercueil,
	Takashi Iwai, Liam Girdwood

On Thu, 3 Dec 2020 22:42:27 +0800, Chuhong Yuan wrote:
> jz4740_i2s_set_sysclk() does not check the return values of clk_get(),
> while the file dereferences the pointers in clk_put().
> Add the missed checks to fix it.

Applied to

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

Thanks!

[1/1] ASoC: jz4740-i2s: add missed checks for clk_get()
      commit: 1c1fb2653a0c2e3f310c07eacd8fc3a10e08c97a

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] 3+ messages in thread

end of thread, other threads:[~2020-12-04 23:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-03 14:42 [PATCH] ASoC: jz4740-i2s: add missed checks for clk_get() Chuhong Yuan
2020-12-03 16:38 ` Paul Cercueil
2020-12-04 23:30 ` 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).