'substream' was dereferenced before the NULL check. Moved the check earlier to prevent NULL pointer dereference.
Cc: Sangbeom Kim sbkim73@samsung.com Cc: Mark Brown broonie@opensource.wolfsonmicro.com Signed-off-by: Sachin Kamat sachin.kamat@linaro.org --- Build tested and based on linux-next 20121115. --- sound/soc/samsung/dma.c | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/sound/soc/samsung/dma.c b/sound/soc/samsung/dma.c index b70964e..e59a4f4 100644 --- a/sound/soc/samsung/dma.c +++ b/sound/soc/samsung/dma.c @@ -114,17 +114,23 @@ static void dma_enqueue(struct snd_pcm_substream *substream) static void audio_buffdone(void *data) { struct snd_pcm_substream *substream = data; - struct runtime_data *prtd = substream->runtime->private_data; + struct runtime_data *prtd;
pr_debug("Entered %s\n", __func__);
+ if (substream) { + prtd = substream->runtime->private_data; + } else { + pr_err("%s: Null data received\n", __func__); + return; + } + if (prtd->state & ST_RUNNING) { prtd->dma_pos += prtd->dma_period; if (prtd->dma_pos >= prtd->dma_end) prtd->dma_pos = prtd->dma_start;
- if (substream) - snd_pcm_period_elapsed(substream); + snd_pcm_period_elapsed(substream);
spin_lock(&prtd->lock); if (!samsung_dma_has_circular()) {