ALSA: core: pcm: simplify locking for timers
[linux-2.6-block.git] / sound / core / pcm.c
index b6d2331a82f70ac8a54b5f61790e456731473bd2..be5714f1bb58c6e71af6a818eef9d48819d9f9d9 100644 (file)
@@ -991,11 +991,13 @@ void snd_pcm_detach_substream(struct snd_pcm_substream *substream)
                       PAGE_ALIGN(sizeof(struct snd_pcm_mmap_control)));
        kfree(runtime->hw_constraints.rules);
        /* Avoid concurrent access to runtime via PCM timer interface */
-       if (substream->timer)
+       if (substream->timer) {
                spin_lock_irq(&substream->timer->lock);
-       substream->runtime = NULL;
-       if (substream->timer)
+               substream->runtime = NULL;
                spin_unlock_irq(&substream->timer->lock);
+       } else {
+               substream->runtime = NULL;
+       }
        kfree(runtime);
        put_pid(substream->pid);
        substream->pid = NULL;