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

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <perex@...>
Cc: <alsa-devel@...>, lkml <linux-kernel@...>
Date: Wednesday, April 16, 2008 - 12:20 pm

bps is unsigned, a negative snd_pcm_format_width() return value is not noticed
    
Signed-off-by: Roel Kluin <12o3l@tiscali.nl>
---
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);
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 6/6] sound/drivers/dummy.c: fix negative snd_pcm_form..., Roel Kluin, (Wed Apr 16, 12:20 pm)
Re: [PATCH 4/6] RTC: rtc-ds1374: fix unsigned new_alarm test, Alessandro Zummo, (Fri Apr 18, 5:58 pm)