Skip to contentSkip to conversation

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

PATCH In review Dan Carpenter 2 participants 2 messages Sep 11, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

sound/core/compress_offload.c +3 -5
index ec2118d..eb60cb8 100644
@@ -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),
#1 lore raw

At Tue, 11 Sep 2012 14:12:43 +0300,

Quoted 8 lines · Dan Carpenter

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.

Applied now. Thanks.

Takashi

Quoted 24 lines
sound/core/compress_offload.c +3 -5
index ec2118d..eb60cb8 100644
@@ -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),