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: seq: More protection for concurrent write and ioctl races
[pandora-kernel.git]
/
sound
/
core
/
seq
/
seq_fifo.c
diff --git
a/sound/core/seq/seq_fifo.c
b/sound/core/seq/seq_fifo.c
index
0d75afa
..
9d429bc
100644
(file)
--- a/
sound/core/seq/seq_fifo.c
+++ b/
sound/core/seq/seq_fifo.c
@@
-72,6
+72,9
@@
void snd_seq_fifo_delete(struct snd_seq_fifo **fifo)
return;
*fifo = NULL;
return;
*fifo = NULL;
+ if (f->pool)
+ snd_seq_pool_mark_closing(f->pool);
+
snd_seq_fifo_clear(f);
/* wake up clients if any */
snd_seq_fifo_clear(f);
/* wake up clients if any */
@@
-122,9
+125,9
@@
int snd_seq_fifo_event_in(struct snd_seq_fifo *f,
return -EINVAL;
snd_use_lock_use(&f->use_lock);
return -EINVAL;
snd_use_lock_use(&f->use_lock);
- err = snd_seq_event_dup(f->pool, event, &cell, 1, NULL); /* always non-blocking */
+ err = snd_seq_event_dup(f->pool, event, &cell, 1, NULL
, NULL
); /* always non-blocking */
if (err < 0) {
if (err < 0) {
- if (
err == -ENOMEM
)
+ if (
(err == -ENOMEM) || (err == -EAGAIN)
)
atomic_inc(&f->overflow);
snd_use_lock_free(&f->use_lock);
return err;
atomic_inc(&f->overflow);
snd_use_lock_free(&f->use_lock);
return err;
@@
-137,6
+140,7
@@
int snd_seq_fifo_event_in(struct snd_seq_fifo *f,
f->tail = cell;
if (f->head == NULL)
f->head = cell;
f->tail = cell;
if (f->head == NULL)
f->head = cell;
+ cell->next = NULL;
f->cells++;
spin_unlock_irqrestore(&f->lock, flags);
f->cells++;
spin_unlock_irqrestore(&f->lock, flags);
@@
-216,6
+220,8
@@
void snd_seq_fifo_cell_putback(struct snd_seq_fifo *f,
spin_lock_irqsave(&f->lock, flags);
cell->next = f->head;
f->head = cell;
spin_lock_irqsave(&f->lock, flags);
cell->next = f->head;
f->head = cell;
+ if (!f->tail)
+ f->tail = cell;
f->cells++;
spin_unlock_irqrestore(&f->lock, flags);
}
f->cells++;
spin_unlock_irqrestore(&f->lock, flags);
}
@@
-261,6
+267,10
@@
int snd_seq_fifo_resize(struct snd_seq_fifo *f, int poolsize)
/* NOTE: overflow flag is not cleared */
spin_unlock_irqrestore(&f->lock, flags);
/* NOTE: overflow flag is not cleared */
spin_unlock_irqrestore(&f->lock, flags);
+ /* close the old pool and wait until all users are gone */
+ snd_seq_pool_mark_closing(oldpool);
+ snd_use_lock_sync(&f->use_lock);
+
/* release cells in old pool */
for (cell = oldhead; cell; cell = next) {
next = cell->next;
/* release cells in old pool */
for (cell = oldhead; cell; cell = next) {
next = cell->next;