From: Takashi Iwai Date: Tue, 7 Jan 2020 07:09:56 +0000 (+0100) Subject: ASoC: Fix NULL dereference at freeing X-Git-Tag: v5.10.7~3493^2^2~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8e3366cad2bfe4e669bfd3758110be90b1dc75aa;p=platform%2Fkernel%2Flinux-rpi.git 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: c64bfc906600 ("ASoC: soc-core: add new pcm_construct/pcm_destruct") Reported-by: Matthias Brugger Tested-by: Ben Ho Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20200107070956.15807-1-tiwai@suse.de Signed-off-by: Mark Brown --- diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c index 1590e80..6a8f26bf 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -520,6 +520,9 @@ void snd_soc_pcm_component_free(struct snd_soc_pcm_runtime *rtd) struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_component *component; + if (!rtd->pcm) + return; + for_each_rtd_components(rtd, rtdcom, component) if (component->driver->pcm_destruct) component->driver->pcm_destruct(component, rtd->pcm);