ALSA: pcm: Check for null pointer of pointer substream before dereferencing it
[linux-2.6-block.git] / sound / core / pcm_memory.c
index 8848d2f3160d80b76362d6b27cd2b44d2a8ab653..b8296b6eb2c19c758b850b6c9f5b9e32dc49b349 100644 (file)
@@ -453,7 +453,6 @@ EXPORT_SYMBOL(snd_pcm_lib_malloc_pages);
  */
 int snd_pcm_lib_free_pages(struct snd_pcm_substream *substream)
 {
-       struct snd_card *card = substream->pcm->card;
        struct snd_pcm_runtime *runtime;
 
        if (PCM_RUNTIME_CHECK(substream))
@@ -462,6 +461,8 @@ int snd_pcm_lib_free_pages(struct snd_pcm_substream *substream)
        if (runtime->dma_area == NULL)
                return 0;
        if (runtime->dma_buffer_p != &substream->dma_buffer) {
+               struct snd_card *card = substream->pcm->card;
+
                /* it's a newly allocated buffer.  release it now. */
                do_free_pages(card, runtime->dma_buffer_p);
                kfree(runtime->dma_buffer_p);