public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] ALSA: compress_core: fix open flags test in snd_compr_open()
@ 2012-09-11 11:12 Dan Carpenter
  2012-09-11 12:28 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2012-09-11 11:12 UTC (permalink / raw)
  To: Jaroslav Kysela
  Cc: Vinod Koul, alsa-devel, Takashi Iwai, kernel-janitors,
	Pierre-Louis Bossart, Jesper Juhl, Namarta Kohli

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 <dan.carpenter@oracle.com>

diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
index ec2118d..eb60cb8 100644
--- a/sound/core/compress_offload.c
+++ b/sound/core/compress_offload.c
@@ -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),

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [patch] ALSA: compress_core: fix open flags test in snd_compr_open()
  2012-09-11 11:12 [patch] ALSA: compress_core: fix open flags test in snd_compr_open() Dan Carpenter
@ 2012-09-11 12:28 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2012-09-11 12:28 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Vinod Koul, alsa-devel, kernel-janitors, Pierre-Louis Bossart,
	Jesper Juhl, Namarta Kohli

At Tue, 11 Sep 2012 14:12:43 +0300,
Dan Carpenter wrote:
> 
> 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 <dan.carpenter@oracle.com>

Applied now.  Thanks.


Takashi

> 
> diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
> index ec2118d..eb60cb8 100644
> --- a/sound/core/compress_offload.c
> +++ b/sound/core/compress_offload.c
> @@ -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),
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-09-11 12:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-11 11:12 [patch] ALSA: compress_core: fix open flags test in snd_compr_open() Dan Carpenter
2012-09-11 12:28 ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox