Skip to content

Commit

Permalink
ALSA: compress_core: fix open flags test in snd_compr_open()
Browse files Browse the repository at this point in the history
O_RDONLY is zero so the original test (f->f_flags & O_RDONLY) is always
false and it will never do compress capture.  The test for O_WRONLY is
also slightly off.  The original test would consider "->flags =
(O_WRONLY | O_RDWR)" as write only instead of rejecting it as invalid.

I've also removed the pr_err() because that could flood dmesg.

Signed-off-by: Dan Carpenter <[email protected]>
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
Dan Carpenter authored and tiwai committed Sep 11, 2012
1 parent 07dc59f commit 81cb324
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions sound/core/compress_offload.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,12 @@ static int snd_compr_open(struct inode *inode, struct file *f)
int maj = imajor(inode);
int ret;

if (f->f_flags & O_WRONLY)
if ((f->f_flags & O_ACCMODE) == O_WRONLY)
dirn = SND_COMPRESS_PLAYBACK;
else if (f->f_flags & O_RDONLY)
else if ((f->f_flags & O_ACCMODE) == O_RDONLY)
dirn = SND_COMPRESS_CAPTURE;
else {
pr_err("invalid direction\n");
else
return -EINVAL;
}

if (maj == snd_major)
compr = snd_lookup_minor_data(iminor(inode),
Expand Down

0 comments on commit 81cb324

Please sign in to comment.