]> Pileus Git - ~andy/linux/commitdiff
ALSA: dice: clear device lock when closing hwdep device
authorClemens Ladisch <clemens@ladisch.de>
Sun, 4 Sep 2011 20:14:54 +0000 (22:14 +0200)
committerClemens Ladisch <clemens@ladisch.de>
Sun, 20 Oct 2013 20:07:57 +0000 (22:07 +0200)
Ensure that misbehaving or aborted userspace programs do not
accidentally keep the lock.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
sound/firewire/dice.c

index 7225878a09cc5b1d45539262851784da6e0e9b42..ef04089bde7f88c4a915ef3320fee56f0d0ba4ba 100644 (file)
@@ -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,