diff options
Diffstat (limited to 'sound/core/timer.c')
-rw-r--r-- | sound/core/timer.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/sound/core/timer.c b/sound/core/timer.c index 2f836ca09860..884c3066b028 100644 --- a/sound/core/timer.c +++ b/sound/core/timer.c | |||
@@ -1618,6 +1618,7 @@ static int snd_timer_user_tselect(struct file *file, | |||
1618 | if (err < 0) | 1618 | if (err < 0) |
1619 | goto __err; | 1619 | goto __err; |
1620 | 1620 | ||
1621 | tu->qhead = tu->qtail = tu->qused = 0; | ||
1621 | kfree(tu->queue); | 1622 | kfree(tu->queue); |
1622 | tu->queue = NULL; | 1623 | tu->queue = NULL; |
1623 | kfree(tu->tqueue); | 1624 | kfree(tu->tqueue); |
@@ -1959,10 +1960,11 @@ static ssize_t snd_timer_user_read(struct file *file, char __user *buffer, | |||
1959 | 1960 | ||
1960 | tu = file->private_data; | 1961 | tu = file->private_data; |
1961 | unit = tu->tread ? sizeof(struct snd_timer_tread) : sizeof(struct snd_timer_read); | 1962 | unit = tu->tread ? sizeof(struct snd_timer_tread) : sizeof(struct snd_timer_read); |
1963 | mutex_lock(&tu->ioctl_lock); | ||
1962 | spin_lock_irq(&tu->qlock); | 1964 | spin_lock_irq(&tu->qlock); |
1963 | while ((long)count - result >= unit) { | 1965 | while ((long)count - result >= unit) { |
1964 | while (!tu->qused) { | 1966 | while (!tu->qused) { |
1965 | wait_queue_t wait; | 1967 | wait_queue_entry_t wait; |
1966 | 1968 | ||
1967 | if ((file->f_flags & O_NONBLOCK) != 0 || result > 0) { | 1969 | if ((file->f_flags & O_NONBLOCK) != 0 || result > 0) { |
1968 | err = -EAGAIN; | 1970 | err = -EAGAIN; |
@@ -1974,7 +1976,9 @@ static ssize_t snd_timer_user_read(struct file *file, char __user *buffer, | |||
1974 | add_wait_queue(&tu->qchange_sleep, &wait); | 1976 | add_wait_queue(&tu->qchange_sleep, &wait); |
1975 | 1977 | ||
1976 | spin_unlock_irq(&tu->qlock); | 1978 | spin_unlock_irq(&tu->qlock); |
1979 | mutex_unlock(&tu->ioctl_lock); | ||
1977 | schedule(); | 1980 | schedule(); |
1981 | mutex_lock(&tu->ioctl_lock); | ||
1978 | spin_lock_irq(&tu->qlock); | 1982 | spin_lock_irq(&tu->qlock); |
1979 | 1983 | ||
1980 | remove_wait_queue(&tu->qchange_sleep, &wait); | 1984 | remove_wait_queue(&tu->qchange_sleep, &wait); |
@@ -1994,7 +1998,6 @@ static ssize_t snd_timer_user_read(struct file *file, char __user *buffer, | |||
1994 | tu->qused--; | 1998 | tu->qused--; |
1995 | spin_unlock_irq(&tu->qlock); | 1999 | spin_unlock_irq(&tu->qlock); |
1996 | 2000 | ||
1997 | mutex_lock(&tu->ioctl_lock); | ||
1998 | if (tu->tread) { | 2001 | if (tu->tread) { |
1999 | if (copy_to_user(buffer, &tu->tqueue[qhead], | 2002 | if (copy_to_user(buffer, &tu->tqueue[qhead], |
2000 | sizeof(struct snd_timer_tread))) | 2003 | sizeof(struct snd_timer_tread))) |
@@ -2004,7 +2007,6 @@ static ssize_t snd_timer_user_read(struct file *file, char __user *buffer, | |||
2004 | sizeof(struct snd_timer_read))) | 2007 | sizeof(struct snd_timer_read))) |
2005 | err = -EFAULT; | 2008 | err = -EFAULT; |
2006 | } | 2009 | } |
2007 | mutex_unlock(&tu->ioctl_lock); | ||
2008 | 2010 | ||
2009 | spin_lock_irq(&tu->qlock); | 2011 | spin_lock_irq(&tu->qlock); |
2010 | if (err < 0) | 2012 | if (err < 0) |
@@ -2014,6 +2016,7 @@ static ssize_t snd_timer_user_read(struct file *file, char __user *buffer, | |||
2014 | } | 2016 | } |
2015 | _error: | 2017 | _error: |
2016 | spin_unlock_irq(&tu->qlock); | 2018 | spin_unlock_irq(&tu->qlock); |
2019 | mutex_unlock(&tu->ioctl_lock); | ||
2017 | return result > 0 ? result : err; | 2020 | return result > 0 ? result : err; |
2018 | } | 2021 | } |
2019 | 2022 | ||