summaryrefslogtreecommitdiffstats
path: root/sound/firewire/dice.c
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2011-09-04 22:14:54 +0200
committerClemens Ladisch <clemens@ladisch.de>2013-10-20 22:07:57 +0200
commit9dd81e3143b57d1bf7e8377ab29b86090baa55a8 (patch)
tree9bd662f8d8e57d97ba044f334cc9a5ea373b8176 /sound/firewire/dice.c
parentALSA: dice: implement hwdep device (diff)
downloadlinux-9dd81e3143b57d1bf7e8377ab29b86090baa55a8.tar.xz
linux-9dd81e3143b57d1bf7e8377ab29b86090baa55a8.zip
ALSA: dice: clear device lock when closing hwdep device
Ensure that misbehaving or aborted userspace programs do not accidentally keep the lock. Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Diffstat (limited to 'sound/firewire/dice.c')
-rw-r--r--sound/firewire/dice.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/sound/firewire/dice.c b/sound/firewire/dice.c
index 7225878a09cc..ef04089bde7f 100644
--- a/sound/firewire/dice.c
+++ b/sound/firewire/dice.c
@@ -966,6 +966,18 @@ static int dice_hwdep_unlock(struct dice *dice)
return err;
}
+static int dice_hwdep_release(struct snd_hwdep *hwdep, struct file *file)
+{
+ struct dice *dice = hwdep->private_data;
+
+ spin_lock_irq(&dice->lock);
+ if (dice->dev_lock_count == -1)
+ dice->dev_lock_count = 0;
+ spin_unlock_irq(&dice->lock);
+
+ return 0;
+}
+
static int dice_hwdep_ioctl(struct snd_hwdep *hwdep, struct file *file,
unsigned int cmd, unsigned long arg)
{
@@ -998,6 +1010,7 @@ static int dice_create_hwdep(struct dice *dice)
{
static const struct snd_hwdep_ops ops = {
.read = dice_hwdep_read,
+ .release = dice_hwdep_release,
.poll = dice_hwdep_poll,
.ioctl = dice_hwdep_ioctl,
.ioctl_compat = dice_hwdep_compat_ioctl,