Skip to content

Commit 02f4865

Browse files
committed
ALSA: core - Define llseek fops
Set no_llseek to llseek file ops of each sound component (but for hwdep). This avoids the implicit BKL invocation via generic_file_llseek() used as default when fops.llseek is NULL. Also call nonseekable_open() at each open ops to ensure the file flags have no seek bit. Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 73029e0 commit 02f4865

7 files changed

Lines changed: 40 additions & 2 deletions

File tree

‎sound/core/control.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ static int snd_ctl_open(struct inode *inode, struct file *file)
5050
struct snd_ctl_file *ctl;
5151
int err;
5252

53+
err = nonseekable_open(inode, file);
54+
if (err < 0)
55+
return err;
56+
5357
card = snd_lookup_minor_data(iminor(inode), SNDRV_DEVICE_TYPE_CONTROL);
5458
if (!card) {
5559
err = -ENODEV;
@@ -1388,6 +1392,7 @@ static const struct file_operations snd_ctl_f_ops =
13881392
.read = snd_ctl_read,
13891393
.open = snd_ctl_open,
13901394
.release = snd_ctl_release,
1395+
.llseek = no_llseek,
13911396
.poll = snd_ctl_poll,
13921397
.unlocked_ioctl = snd_ctl_ioctl,
13931398
.compat_ioctl = snd_ctl_ioctl_compat,

‎sound/core/oss/mixer_oss.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ static int snd_mixer_oss_open(struct inode *inode, struct file *file)
4343
struct snd_mixer_oss_file *fmixer;
4444
int err;
4545

46+
err = nonseekable_open(inode, file);
47+
if (err < 0)
48+
return err;
49+
4650
card = snd_lookup_oss_minor_data(iminor(inode),
4751
SNDRV_OSS_DEVICE_TYPE_MIXER);
4852
if (card == NULL)
@@ -397,6 +401,7 @@ static const struct file_operations snd_mixer_oss_f_ops =
397401
.owner = THIS_MODULE,
398402
.open = snd_mixer_oss_open,
399403
.release = snd_mixer_oss_release,
404+
.llseek = no_llseek,
400405
.unlocked_ioctl = snd_mixer_oss_ioctl,
401406
.compat_ioctl = snd_mixer_oss_ioctl_compat,
402407
};

‎sound/core/oss/pcm_oss.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2379,6 +2379,10 @@ static int snd_pcm_oss_open(struct inode *inode, struct file *file)
23792379
int nonblock;
23802380
wait_queue_t wait;
23812381

2382+
err = nonseekable_open(inode, file);
2383+
if (err < 0)
2384+
return err;
2385+
23822386
pcm = snd_lookup_oss_minor_data(iminor(inode),
23832387
SNDRV_OSS_DEVICE_TYPE_PCM);
23842388
if (pcm == NULL) {
@@ -2977,6 +2981,7 @@ static const struct file_operations snd_pcm_oss_f_reg =
29772981
.write = snd_pcm_oss_write,
29782982
.open = snd_pcm_oss_open,
29792983
.release = snd_pcm_oss_release,
2984+
.llseek = no_llseek,
29802985
.poll = snd_pcm_oss_poll,
29812986
.unlocked_ioctl = snd_pcm_oss_ioctl,
29822987
.compat_ioctl = snd_pcm_oss_ioctl_compat,

‎sound/core/pcm_native.c‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2107,7 +2107,9 @@ static int snd_pcm_open_file(struct file *file,
21072107
static int snd_pcm_playback_open(struct inode *inode, struct file *file)
21082108
{
21092109
struct snd_pcm *pcm;
2110-
2110+
int err = nonseekable_open(inode, file);
2111+
if (err < 0)
2112+
return err;
21112113
pcm = snd_lookup_minor_data(iminor(inode),
21122114
SNDRV_DEVICE_TYPE_PCM_PLAYBACK);
21132115
return snd_pcm_open(file, pcm, SNDRV_PCM_STREAM_PLAYBACK);
@@ -2116,7 +2118,9 @@ static int snd_pcm_playback_open(struct inode *inode, struct file *file)
21162118
static int snd_pcm_capture_open(struct inode *inode, struct file *file)
21172119
{
21182120
struct snd_pcm *pcm;
2119-
2121+
int err = nonseekable_open(inode, file);
2122+
if (err < 0)
2123+
return err;
21202124
pcm = snd_lookup_minor_data(iminor(inode),
21212125
SNDRV_DEVICE_TYPE_PCM_CAPTURE);
21222126
return snd_pcm_open(file, pcm, SNDRV_PCM_STREAM_CAPTURE);
@@ -3450,6 +3454,7 @@ const struct file_operations snd_pcm_f_ops[2] = {
34503454
.aio_write = snd_pcm_aio_write,
34513455
.open = snd_pcm_playback_open,
34523456
.release = snd_pcm_release,
3457+
.llseek = no_llseek,
34533458
.poll = snd_pcm_playback_poll,
34543459
.unlocked_ioctl = snd_pcm_playback_ioctl,
34553460
.compat_ioctl = snd_pcm_ioctl_compat,
@@ -3463,6 +3468,7 @@ const struct file_operations snd_pcm_f_ops[2] = {
34633468
.aio_read = snd_pcm_aio_read,
34643469
.open = snd_pcm_capture_open,
34653470
.release = snd_pcm_release,
3471+
.llseek = no_llseek,
34663472
.poll = snd_pcm_capture_poll,
34673473
.unlocked_ioctl = snd_pcm_capture_ioctl,
34683474
.compat_ioctl = snd_pcm_ioctl_compat,

‎sound/core/rawmidi.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,10 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file)
376376
if ((file->f_flags & O_APPEND) && !(file->f_flags & O_NONBLOCK))
377377
return -EINVAL; /* invalid combination */
378378

379+
err = nonseekable_open(inode, file);
380+
if (err < 0)
381+
return err;
382+
379383
if (maj == snd_major) {
380384
rmidi = snd_lookup_minor_data(iminor(inode),
381385
SNDRV_DEVICE_TYPE_RAWMIDI);
@@ -1391,6 +1395,7 @@ static const struct file_operations snd_rawmidi_f_ops =
13911395
.write = snd_rawmidi_write,
13921396
.open = snd_rawmidi_open,
13931397
.release = snd_rawmidi_release,
1398+
.llseek = no_llseek,
13941399
.poll = snd_rawmidi_poll,
13951400
.unlocked_ioctl = snd_rawmidi_ioctl,
13961401
.compat_ioctl = snd_rawmidi_ioctl_compat,

‎sound/core/seq/seq_clientmgr.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,11 @@ static int snd_seq_open(struct inode *inode, struct file *file)
318318
int c, mode; /* client id */
319319
struct snd_seq_client *client;
320320
struct snd_seq_user_client *user;
321+
int err;
322+
323+
err = nonseekable_open(inode, file);
324+
if (err < 0)
325+
return err;
321326

322327
if (mutex_lock_interruptible(&register_mutex))
323328
return -ERESTARTSYS;
@@ -2550,6 +2555,7 @@ static const struct file_operations snd_seq_f_ops =
25502555
.write = snd_seq_write,
25512556
.open = snd_seq_open,
25522557
.release = snd_seq_release,
2558+
.llseek = no_llseek,
25532559
.poll = snd_seq_poll,
25542560
.unlocked_ioctl = snd_seq_ioctl,
25552561
.compat_ioctl = snd_seq_ioctl_compat,

‎sound/core/timer.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,6 +1237,11 @@ static void snd_timer_user_tinterrupt(struct snd_timer_instance *timeri,
12371237
static int snd_timer_user_open(struct inode *inode, struct file *file)
12381238
{
12391239
struct snd_timer_user *tu;
1240+
int err;
1241+
1242+
err = nonseekable_open(inode, file);
1243+
if (err < 0)
1244+
return err;
12401245

12411246
tu = kzalloc(sizeof(*tu), GFP_KERNEL);
12421247
if (tu == NULL)
@@ -1921,6 +1926,7 @@ static const struct file_operations snd_timer_f_ops =
19211926
.read = snd_timer_user_read,
19221927
.open = snd_timer_user_open,
19231928
.release = snd_timer_user_release,
1929+
.llseek = no_llseek,
19241930
.poll = snd_timer_user_poll,
19251931
.unlocked_ioctl = snd_timer_user_ioctl,
19261932
.compat_ioctl = snd_timer_user_ioctl_compat,

0 commit comments

Comments
 (0)