Skip to content

Commit d6c098a

Browse files
computersforpeacebroonie
authored andcommitted
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: 99b04f4 ("ASoC: add Component level pcm_new/pcm_free") Signed-off-by: Brian Norris <[email protected]> Signed-off-by: Mark Brown <[email protected]>
1 parent c1ae3cf commit d6c098a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

sound/soc/soc-core.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3326,15 +3326,19 @@ static int snd_soc_platform_drv_pcm_new(struct snd_soc_pcm_runtime *rtd)
33263326
{
33273327
struct snd_soc_platform *platform = rtd->platform;
33283328

3329-
return platform->driver->pcm_new(rtd);
3329+
if (platform->driver->pcm_new)
3330+
return platform->driver->pcm_new(rtd);
3331+
else
3332+
return 0;
33303333
}
33313334

33323335
static void snd_soc_platform_drv_pcm_free(struct snd_pcm *pcm)
33333336
{
33343337
struct snd_soc_pcm_runtime *rtd = pcm->private_data;
33353338
struct snd_soc_platform *platform = rtd->platform;
33363339

3337-
platform->driver->pcm_free(pcm);
3340+
if (platform->driver->pcm_free)
3341+
platform->driver->pcm_free(pcm);
33383342
}
33393343

33403344
/**

0 commit comments

Comments
 (0)