Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Linux: Kernel

[PATCH 6/6] sound/drivers/dummy.c: fix negative snd_pcm_format_width() check

 

 

Linux kernel RSS feed   Index | Next | Previous | View Threaded


12o3l at tiscali

Apr 16, 2008, 9:20 AM

Post #1 of 2 (136 views)
Permalink
[PATCH 6/6] sound/drivers/dummy.c: fix negative snd_pcm_format_width() check

bps is unsigned, a negative snd_pcm_format_width() return value is not noticed

Signed-off-by: Roel Kluin <12o3l [at] tiscali>
---
diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c
index a240eae..1c88977 100644
--- a/sound/drivers/dummy.c
+++ b/sound/drivers/dummy.c
@@ -230,13 +230,14 @@ static int snd_card_dummy_pcm_prepare(struct snd_pcm_substream *substream)
{
struct snd_pcm_runtime *runtime = substream->runtime;
struct snd_dummy_pcm *dpcm = runtime->private_data;
- unsigned int bps;
+ int bps;
+
+ bps = snd_pcm_format_width(runtime->format) * runtime->rate *
+ runtime->channels / 8;

- bps = runtime->rate * runtime->channels;
- bps *= snd_pcm_format_width(runtime->format);
- bps /= 8;
if (bps <= 0)
return -EINVAL;
+
dpcm->pcm_bps = bps;
dpcm->pcm_jiffie = bps / HZ;
dpcm->pcm_size = snd_pcm_lib_buffer_bytes(substream);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


tiwai at suse

Apr 16, 2008, 9:31 AM

Post #2 of 2 (130 views)
Permalink
Re: [alsa-devel] [PATCH 6/6] sound/drivers/dummy.c: fix negative snd_pcm_format_width() check [In reply to]

At Wed, 16 Apr 2008 18:20:33 +0200,
Roel Kluin wrote:
>
> bps is unsigned, a negative snd_pcm_format_width() return value is not noticed
>
> Signed-off-by: Roel Kluin <12o3l [at] tiscali>

Applied to ALSA tree. Thanks.


Takashi

> ---
> diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c
> index a240eae..1c88977 100644
> --- a/sound/drivers/dummy.c
> +++ b/sound/drivers/dummy.c
> @@ -230,13 +230,14 @@ static int snd_card_dummy_pcm_prepare(struct snd_pcm_substream *substream)
> {
> struct snd_pcm_runtime *runtime = substream->runtime;
> struct snd_dummy_pcm *dpcm = runtime->private_data;
> - unsigned int bps;
> + int bps;
> +
> + bps = snd_pcm_format_width(runtime->format) * runtime->rate *
> + runtime->channels / 8;
>
> - bps = runtime->rate * runtime->channels;
> - bps *= snd_pcm_format_width(runtime->format);
> - bps /= 8;
> if (bps <= 0)
> return -EINVAL;
> +
> dpcm->pcm_bps = bps;
> dpcm->pcm_jiffie = bps / HZ;
> dpcm->pcm_size = snd_pcm_lib_buffer_bytes(substream);
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel [at] alsa-project
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Linux kernel RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.