ASoC: imx-pcm-dma: check kzalloc return value in function snd_imx_open
authorRichard Zhao <richard.zhao@freescale.com>
Tue, 18 Sep 2012 09:20:05 +0000 (17:20 +0800)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Wed, 19 Sep 2012 02:52:42 +0000 (22:52 -0400)
It fixed smatch warning:
sound/soc/fsl/imx-pcm-dma.c:112 snd_imx_open() error: potential null dereference 'dma_data'.  (kzalloc returns null)

Signed-off-by: Richard Zhao <richard.zhao@freescale.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
sound/soc/fsl/imx-pcm-dma.c

index 48f9d88..a23505a 100644 (file)
@@ -109,6 +109,9 @@ static int snd_imx_open(struct snd_pcm_substream *substream)
        dma_params = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
 
        dma_data = kzalloc(sizeof(*dma_data), GFP_KERNEL);
+       if (!dma_data)
+               return -ENOMEM;
+
        dma_data->peripheral_type = dma_params->shared_peripheral ?
                                        IMX_DMATYPE_SSI_SP : IMX_DMATYPE_SSI;
        dma_data->priority = DMA_PRIO_HIGH;