Skip to content

Commit

Permalink
ALSA: core: pcm: simplify locking for timers
Browse files Browse the repository at this point in the history
Fix sparse warning:

sound/core/pcm.c:999:9: warning: context imbalance in
'snd_pcm_detach_substream' - different lock contexts for basic block

There's no real reason to test the same thing twice, and it's simpler
have linear sequences.

Signed-off-by: Pierre-Louis Bossart <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
plbossart authored and tiwai committed Sep 3, 2020
1 parent 685a04a commit 931522b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions sound/core/pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 931522b

Please sign in to comment.