public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: alsa-devel@alsa-project.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch] oss/sb_audio: prevent divide by zero bug
Date: Mon, 20 Aug 2012 08:24:35 +0000	[thread overview]
Message-ID: <s5h393irmws.wl%tiwai@suse.de> (raw)
In-Reply-To: <20120818155515.GA22424@elgon.mountain>

At Sat, 18 Aug 2012 18:55:15 +0300,
Dan Carpenter wrote:
> 
> Speed comes from get_user() in audio_ioctl().  We use it to set the "s"
> variable before clamping it to valid values so it could lead to a divide
> by zero bug.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Thanks, applied now.


Takashi


> diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
> index 733b014..b2b3c01 100644
> --- a/sound/oss/sb_audio.c
> +++ b/sound/oss/sb_audio.c
> @@ -575,13 +575,15 @@ static int jazz16_audio_set_speed(int dev, int speed)
>  	if (speed > 0)
>  	{
>  		int tmp;
> -		int s = speed * devc->channels;
> +		int s;
>  
>  		if (speed < 5000)
>  			speed = 5000;
>  		if (speed > 44100)
>  			speed = 44100;
>  
> +		s = speed * devc->channels;
> +
>  		devc->tconst = (256 - ((1000000 + s / 2) / s)) & 0xff;
>  
>  		tmp = 256 - devc->tconst;
> 

      reply	other threads:[~2012-08-20  8:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-18 15:55 [patch] oss/sb_audio: prevent divide by zero bug Dan Carpenter
2012-08-20  8:24 ` Takashi Iwai [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=s5h393irmws.wl%tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=dan.carpenter@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox