aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorJonathan Corbet <corbet@lwn.net>2009-02-06 17:25:24 -0500
committerJonathan Corbet <corbet@lwn.net>2009-03-16 10:32:27 -0400
commitdb1dd4d376134eba0e08af523b61cc566a4ea1cd (patch)
tree8882c673abbaa5713511b7046493fa862b9140d1 /sound
parent684999149002dd046269666a390458e0acb38280 (diff)
Use f_lock to protect f_flags
Traditionally, changes to struct file->f_flags have been done under BKL protection, or with no protection at all. This patch causes all f_flags changes after file open/creation time to be done under protection of f_lock. This allows the removal of some BKL usage and fixes a number of longstanding (if microscopic) races. Reviewed-by: Christoph Hellwig <hch@lst.de> Cc: Al Viro <viro@ZenIV.linux.org.uk> Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Diffstat (limited to 'sound')
-rw-r--r--sound/core/oss/pcm_oss.c2
-rw-r--r--sound/oss/au1550_ac97.c2
-rw-r--r--sound/oss/audio.c2
-rw-r--r--sound/oss/sh_dac_audio.c2
-rw-r--r--sound/oss/swarm_cs4297a.c2
-rw-r--r--sound/oss/vwsnd.c2
6 files changed, 12 insertions, 0 deletions
diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
index 0a1798eafb0b..d4460f18e76c 100644
--- a/sound/core/oss/pcm_oss.c
+++ b/sound/core/oss/pcm_oss.c
@@ -1895,7 +1895,9 @@ static int snd_pcm_oss_set_fragment(struct snd_pcm_oss_file *pcm_oss_file, unsig
1895 1895
1896static int snd_pcm_oss_nonblock(struct file * file) 1896static int snd_pcm_oss_nonblock(struct file * file)
1897{ 1897{
1898 spin_lock(&file->f_lock);
1898 file->f_flags |= O_NONBLOCK; 1899 file->f_flags |= O_NONBLOCK;
1900 spin_unlock(&file->f_lock);
1899 return 0; 1901 return 0;
1900} 1902}
1901 1903
diff --git a/sound/oss/au1550_ac97.c b/sound/oss/au1550_ac97.c
index 81e1f443d094..4191acccbcdb 100644
--- a/sound/oss/au1550_ac97.c
+++ b/sound/oss/au1550_ac97.c
@@ -1627,7 +1627,9 @@ au1550_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
1627 sizeof(abinfo)) ? -EFAULT : 0; 1627 sizeof(abinfo)) ? -EFAULT : 0;
1628 1628
1629 case SNDCTL_DSP_NONBLOCK: 1629 case SNDCTL_DSP_NONBLOCK:
1630 spin_lock(&file->f_lock);
1630 file->f_flags |= O_NONBLOCK; 1631 file->f_flags |= O_NONBLOCK;
1632 spin_unlock(&file->f_lock);
1631 return 0; 1633 return 0;
1632 1634
1633 case SNDCTL_DSP_GETODELAY: 1635 case SNDCTL_DSP_GETODELAY:
diff --git a/sound/oss/audio.c b/sound/oss/audio.c
index 89bd27a5e865..b69c05b7ea7b 100644
--- a/sound/oss/audio.c
+++ b/sound/oss/audio.c
@@ -433,7 +433,9 @@ int audio_ioctl(int dev, struct file *file, unsigned int cmd, void __user *arg)
433 return dma_ioctl(dev, cmd, arg); 433 return dma_ioctl(dev, cmd, arg);
434 434
435 case SNDCTL_DSP_NONBLOCK: 435 case SNDCTL_DSP_NONBLOCK:
436 spin_lock(&file->f_lock);
436 file->f_flags |= O_NONBLOCK; 437 file->f_flags |= O_NONBLOCK;
438 spin_unlock(&file->f_lock);
437 return 0; 439 return 0;
438 440
439 case SNDCTL_DSP_GETCAPS: 441 case SNDCTL_DSP_GETCAPS:
diff --git a/sound/oss/sh_dac_audio.c b/sound/oss/sh_dac_audio.c
index e5d423994918..78cfb66e4c59 100644
--- a/sound/oss/sh_dac_audio.c
+++ b/sound/oss/sh_dac_audio.c
@@ -135,7 +135,9 @@ static int dac_audio_ioctl(struct inode *inode, struct file *file,
135 return put_user(AFMT_U8, (int *)arg); 135 return put_user(AFMT_U8, (int *)arg);
136 136
137 case SNDCTL_DSP_NONBLOCK: 137 case SNDCTL_DSP_NONBLOCK:
138 spin_lock(&file->f_lock);
138 file->f_flags |= O_NONBLOCK; 139 file->f_flags |= O_NONBLOCK;
140 spin_unlock(&file->f_lock);
139 return 0; 141 return 0;
140 142
141 case SNDCTL_DSP_GETCAPS: 143 case SNDCTL_DSP_GETCAPS:
diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
index 41562ecde5bb..1edab7b4ea83 100644
--- a/sound/oss/swarm_cs4297a.c
+++ b/sound/oss/swarm_cs4297a.c
@@ -2200,7 +2200,9 @@ static int cs4297a_ioctl(struct inode *inode, struct file *file,
2200 sizeof(abinfo)) ? -EFAULT : 0; 2200 sizeof(abinfo)) ? -EFAULT : 0;
2201 2201
2202 case SNDCTL_DSP_NONBLOCK: 2202 case SNDCTL_DSP_NONBLOCK:
2203 spin_lock(&file->f_lock);
2203 file->f_flags |= O_NONBLOCK; 2204 file->f_flags |= O_NONBLOCK;
2205 spin_unlock(&file->f_lock);
2204 return 0; 2206 return 0;
2205 2207
2206 case SNDCTL_DSP_GETODELAY: 2208 case SNDCTL_DSP_GETODELAY:
diff --git a/sound/oss/vwsnd.c b/sound/oss/vwsnd.c
index 78b8acc7c3b9..187f72750e8f 100644
--- a/sound/oss/vwsnd.c
+++ b/sound/oss/vwsnd.c
@@ -2673,7 +2673,9 @@ static int vwsnd_audio_do_ioctl(struct inode *inode,
2673 2673
2674 case SNDCTL_DSP_NONBLOCK: /* _SIO ('P',14) */ 2674 case SNDCTL_DSP_NONBLOCK: /* _SIO ('P',14) */
2675 DBGX("SNDCTL_DSP_NONBLOCK\n"); 2675 DBGX("SNDCTL_DSP_NONBLOCK\n");
2676 spin_lock(&file->f_lock);
2676 file->f_flags |= O_NONBLOCK; 2677 file->f_flags |= O_NONBLOCK;
2678 spin_unlock(&file->f_lock);
2677 return 0; 2679 return 0;
2678 2680
2679 case SNDCTL_DSP_RESET: /* _SIO ('P', 0) */ 2681 case SNDCTL_DSP_RESET: /* _SIO ('P', 0) */