git.openpandora.org
/
pandora-kernel.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ALSA: PCM: Fix some races at disconnection
[pandora-kernel.git]
/
sound
/
core
/
pcm.c
diff --git
a/sound/core/pcm.c
b/sound/core/pcm.c
index
ee9abb2
..
86440e4
100644
(file)
--- a/
sound/core/pcm.c
+++ b/
sound/core/pcm.c
@@
-21,6
+21,7
@@
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/slab.h>
+#include <linux/module.h>
#include <linux/time.h>
#include <linux/mutex.h>
#include <sound/core.h>
#include <linux/time.h>
#include <linux/mutex.h>
#include <sound/core.h>
@@
-1045,11
+1046,15
@@
static int snd_pcm_dev_disconnect(struct snd_device *device)
if (list_empty(&pcm->list))
goto unlock;
if (list_empty(&pcm->list))
goto unlock;
+ mutex_lock(&pcm->open_mutex);
list_del_init(&pcm->list);
for (cidx = 0; cidx < 2; cidx++)
list_del_init(&pcm->list);
for (cidx = 0; cidx < 2; cidx++)
- for (substream = pcm->streams[cidx].substream; substream; substream = substream->next)
+ for (substream = pcm->streams[cidx].substream; substream; substream = substream->next) {
+ snd_pcm_stream_lock_irq(substream);
if (substream->runtime)
substream->runtime->status->state = SNDRV_PCM_STATE_DISCONNECTED;
if (substream->runtime)
substream->runtime->status->state = SNDRV_PCM_STATE_DISCONNECTED;
+ snd_pcm_stream_unlock_irq(substream);
+ }
list_for_each_entry(notify, &snd_pcm_notify_list, list) {
notify->n_disconnect(pcm);
}
list_for_each_entry(notify, &snd_pcm_notify_list, list) {
notify->n_disconnect(pcm);
}
@@
-1065,6
+1070,7
@@
static int snd_pcm_dev_disconnect(struct snd_device *device)
}
snd_unregister_device(devtype, pcm->card, pcm->device);
}
}
snd_unregister_device(devtype, pcm->card, pcm->device);
}
+ mutex_unlock(&pcm->open_mutex);
unlock:
mutex_unlock(®ister_mutex);
return 0;
unlock:
mutex_unlock(®ister_mutex);
return 0;