Skip to content

Commit 8e3366c

Browse files
tiwaibroonie
authored andcommitted
ASoC: Fix NULL dereference at freeing
When an ASoC driver with pcm_destruct component ops is freed before the PCM object instantiation (e.g. deferring the probe), it hits an Oops at snd_soc_pcm_component_free() that calls the pcm_destruct ops unconditionally. Fix it by adding a NULL-check of rtd->pcm before calling callbacks. Fixes: c64bfc9 ("ASoC: soc-core: add new pcm_construct/pcm_destruct") Reported-by: Matthias Brugger <[email protected]> Tested-by: Ben Ho <[email protected]> Signed-off-by: Takashi Iwai <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 869bced commit 8e3366c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

sound/soc/soc-component.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,9 @@ void snd_soc_pcm_component_free(struct snd_soc_pcm_runtime *rtd)
520520
struct snd_soc_rtdcom_list *rtdcom;
521521
struct snd_soc_component *component;
522522

523+
if (!rtd->pcm)
524+
return;
525+
523526
for_each_rtd_components(rtd, rtdcom, component)
524527
if (component->driver->pcm_destruct)
525528
component->driver->pcm_destruct(component, rtd->pcm);

0 commit comments

Comments
 (0)