Commit d6c098a1 authored by Brian Norris's avatar Brian Norris Committed by Mark Brown

ASoC: don't dereference NULL pcm_{new,free}

Not all platform drivers have pcm_{new,free} callbacks. Seen with a
"snd-soc-dummy" codec from sound/soc/rockchip/rk3399_gru_sound.c.

Fixes: 99b04f4c ("ASoC: add Component level pcm_new/pcm_free")
Signed-off-by: default avatarBrian Norris <briannorris@chromium.org>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent c1ae3cfa
...@@ -3326,7 +3326,10 @@ static int snd_soc_platform_drv_pcm_new(struct snd_soc_pcm_runtime *rtd) ...@@ -3326,7 +3326,10 @@ static int snd_soc_platform_drv_pcm_new(struct snd_soc_pcm_runtime *rtd)
{ {
struct snd_soc_platform *platform = rtd->platform; struct snd_soc_platform *platform = rtd->platform;
return platform->driver->pcm_new(rtd); if (platform->driver->pcm_new)
return platform->driver->pcm_new(rtd);
else
return 0;
} }
static void snd_soc_platform_drv_pcm_free(struct snd_pcm *pcm) static void snd_soc_platform_drv_pcm_free(struct snd_pcm *pcm)
...@@ -3334,7 +3337,8 @@ static void snd_soc_platform_drv_pcm_free(struct snd_pcm *pcm) ...@@ -3334,7 +3337,8 @@ static void snd_soc_platform_drv_pcm_free(struct snd_pcm *pcm)
struct snd_soc_pcm_runtime *rtd = pcm->private_data; struct snd_soc_pcm_runtime *rtd = pcm->private_data;
struct snd_soc_platform *platform = rtd->platform; struct snd_soc_platform *platform = rtd->platform;
platform->driver->pcm_free(pcm); if (platform->driver->pcm_free)
platform->driver->pcm_free(pcm);
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment