kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] sound: oss/sb_audio: cap value in sb201_audio_set_speed()
@ 2012-11-17 15:08 Dan Carpenter
  2012-11-18  9:28 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2012-11-17 15:08 UTC (permalink / raw)
  To: Jaroslav Kysela; +Cc: Takashi Iwai, alsa-devel, kernel-janitors

We set "s" before we have capped "speed" so it could be the wrong value.
This could lead to a divide by zero bug.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
I fixed a similar bug in this file in Aug.  I'm not sure how I missed
this one.  I don't see any others I missed.

diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
index b2b3c01..048439a 100644
--- a/sound/oss/sb_audio.c
+++ b/sound/oss/sb_audio.c
@@ -442,7 +442,7 @@ static int sb201_audio_set_speed(int dev, int speed)
 {
 	sb_devc *devc = audio_devs[dev]->devc;
 	int tmp;
-	int s = speed * devc->channels;
+	int s;
 
 	if (speed > 0)
 	{
@@ -452,6 +452,7 @@ static int sb201_audio_set_speed(int dev, int speed)
 			speed = 44100;
 		if (devc->opened & OPEN_READ && speed > 15000)
 			speed = 15000;
+		s = speed * devc->channels;
 		devc->tconst = (256 - ((1000000 + s / 2) / s)) & 0xff;
 		tmp = 256 - devc->tconst;
 		speed = ((1000000 + tmp / 2) / tmp) / devc->channels;

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

* Re: [patch] sound: oss/sb_audio: cap value in sb201_audio_set_speed()
  2012-11-17 15:08 [patch] sound: oss/sb_audio: cap value in sb201_audio_set_speed() Dan Carpenter
@ 2012-11-18  9:28 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2012-11-18  9:28 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: alsa-devel, kernel-janitors

At Sat, 17 Nov 2012 18:08:57 +0300,
Dan Carpenter wrote:
> 
> We set "s" before we have capped "speed" so it could be the wrong value.
> This could lead to a divide by zero bug.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> I fixed a similar bug in this file in Aug.  I'm not sure how I missed
> this one.  I don't see any others I missed.

Thanks, applied.


Takashi

> 
> diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
> index b2b3c01..048439a 100644
> --- a/sound/oss/sb_audio.c
> +++ b/sound/oss/sb_audio.c
> @@ -442,7 +442,7 @@ static int sb201_audio_set_speed(int dev, int speed)
>  {
>  	sb_devc *devc = audio_devs[dev]->devc;
>  	int tmp;
> -	int s = speed * devc->channels;
> +	int s;
>  
>  	if (speed > 0)
>  	{
> @@ -452,6 +452,7 @@ static int sb201_audio_set_speed(int dev, int speed)
>  			speed = 44100;
>  		if (devc->opened & OPEN_READ && speed > 15000)
>  			speed = 15000;
> +		s = speed * devc->channels;
>  		devc->tconst = (256 - ((1000000 + s / 2) / s)) & 0xff;
>  		tmp = 256 - devc->tconst;
>  		speed = ((1000000 + tmp / 2) / tmp) / devc->channels;
> 

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

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

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-17 15:08 [patch] sound: oss/sb_audio: cap value in sb201_audio_set_speed() Dan Carpenter
2012-11-18  9: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;
as well as URLs for NNTP newsgroup(s).