]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
OSS trident: fix locking around write_voice_regs
authorMuli Ben-Yehuda <muli@il.ibm.com>
Tue, 17 Jul 2007 11:05:15 +0000 (04:05 -0700)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Tue, 17 Jul 2007 17:23:10 +0000 (10:23 -0700)
trident_write_voice_regs() was getting called with the card spinlock held in
only some cases.  Fix it.

Explanation: we allocate a new virtual channel in open, and then we frob some
hardware registers (in write_voice_regs) for that channel.  But the hardware
registers are shared with other channels, which may be trying to frob the some
registers (albeit for another channel) via ioctl(SNDCTL_DSP_SPEED).

Fixed bugzilla.kernel.org bug #8172 (http://bugme.osdl.org/show_bug.cgi?id=8172)

Signed-off-by: Muli Ben-Yehuda <muli@il.ibm.com>
Cc: <tammy000@gmail.com>
Cc: <bunk@stusta.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
sound/oss/trident.c

index 3e408f49192792ba35c123e164d374cc31f0fa13..2e3e78e1bf67d3b487ea94035e56279d47193600 100644 (file)
@@ -2702,6 +2702,7 @@ trident_open(struct inode *inode, struct file *file)
        struct trident_card *card = devs;
        struct trident_state *state = NULL;
        struct dmabuf *dmabuf = NULL;
+       unsigned long flags;
 
        /* Added by Matt Wu 01-05-2001 */
        /* TODO: there's some redundacy here wrt the check below */
@@ -2779,7 +2780,9 @@ trident_open(struct inode *inode, struct file *file)
                        /* set default channel attribute to normal playback */
                        dmabuf->channel->attribute = CHANNEL_PB;
                }
+               spin_lock_irqsave(&card->lock, flags);
                trident_set_dac_rate(state, 8000);
+               spin_unlock_irqrestore(&card->lock, flags);
        }
 
        if (file->f_mode & FMODE_READ) {
@@ -2797,7 +2800,9 @@ trident_open(struct inode *inode, struct file *file)
                        dmabuf->channel->attribute = (CHANNEL_REC | PCM_LR |
                                                      MONO_MIX);
                }
+               spin_lock_irqsave(&card->lock, flags);
                trident_set_adc_rate(state, 8000);
+               spin_unlock_irqrestore(&card->lock, flags);
 
                /* Added by Matt Wu 01-05-2001 */
                if (card->pci_id == PCI_DEVICE_ID_ALI_5451)