ASoC: core: Fix possible NULL pointer dereference of pcm->config
authorXiubo Li <Li.Xiubo@freescale.com>
Thu, 16 Jan 2014 08:08:04 +0000 (16:08 +0800)
committerMark Brown <broonie@linaro.org>
Thu, 16 Jan 2014 14:11:49 +0000 (14:11 +0000)
Since the soc generic dmaengine pcm driver allows using the defualt settings,
so the pcm->config maybe NULL.

Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
sound/soc/soc-generic-dmaengine-pcm.c

index 560a7787d8a761735fc51e45dc290f14934ac0bb..5bace124ef438f9bea6a1ad16941df48760e8276 100644 (file)
@@ -176,17 +176,20 @@ static struct dma_chan *dmaengine_pcm_compat_request_channel(
 {
        struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform);
        struct snd_dmaengine_dai_dma_data *dma_data;
+       dma_filter_fn fn = NULL;
 
        dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
 
        if ((pcm->flags & SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX) && pcm->chan[0])
                return pcm->chan[0];
 
-       if (pcm->config->compat_request_channel)
+       if (pcm->config && pcm->config->compat_request_channel)
                return pcm->config->compat_request_channel(rtd, substream);
 
-       return snd_dmaengine_pcm_request_channel(pcm->config->compat_filter_fn,
-                                                dma_data->filter_data);
+       if (pcm->config)
+               fn = pcm->config->compat_filter_fn;
+
+       return snd_dmaengine_pcm_request_channel(fn, dma_data->filter_data);
 }
 
 static bool dmaengine_pcm_can_report_residue(struct dma_chan *chan)