Commit 81cb3246 authored by Dan Carpenter's avatar Dan Carpenter Committed by Takashi Iwai

ALSA: compress_core: fix open flags test in snd_compr_open()

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: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 07dc59f0
...@@ -80,14 +80,12 @@ static int snd_compr_open(struct inode *inode, struct file *f) ...@@ -80,14 +80,12 @@ static int snd_compr_open(struct inode *inode, struct file *f)
int maj = imajor(inode); int maj = imajor(inode);
int ret; int ret;
if (f->f_flags & O_WRONLY) if ((f->f_flags & O_ACCMODE) == O_WRONLY)
dirn = SND_COMPRESS_PLAYBACK; dirn = SND_COMPRESS_PLAYBACK;
else if (f->f_flags & O_RDONLY) else if ((f->f_flags & O_ACCMODE) == O_RDONLY)
dirn = SND_COMPRESS_CAPTURE; dirn = SND_COMPRESS_CAPTURE;
else { else
pr_err("invalid direction\n");
return -EINVAL; return -EINVAL;
}
if (maj == snd_major) if (maj == snd_major)
compr = snd_lookup_minor_data(iminor(inode), compr = snd_lookup_minor_data(iminor(inode),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment