[alsa-devel] [PATCH 4/4] compress: fix arithmetic exception in compress_get_hpointer

Vinod Koul vinod.koul at intel.com
Mon Feb 18 15:15:15 CET 2013


From: Xuemin Su <xuemin.su at intel.com>

In compress_get_hpointer, check for invalid sample
rate to prevent devide-by-zero exceptions

Signed-off-by: Xuemin Su <xuemin.su at intel.com>
Signed-off-by: He Bo <bo.he at intel.com>
Signed-off-by: Vinod Koul <vinod.koul at intel.com>
---
 compress.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/compress.c b/compress.c
index b035e4a..27c03d9 100644
--- a/compress.c
+++ b/compress.c
@@ -286,6 +286,8 @@ int compress_get_hpointer(struct compress *compress,
 
 	if (ioctl(compress->fd, SNDRV_COMPRESS_AVAIL, &kavail))
 		return oops(compress, errno, "cannot get avail");
+	if (0 == kavail.tstamp.sampling_rate)
+		return oops(compress, errno, "invalid paramter");
 	*avail = (unsigned int)kavail.avail;
 	time = kavail.tstamp.pcm_io_frames / kavail.tstamp.sampling_rate;
 	tstamp->tv_sec = time;
-- 
1.7.0.4



More information about the Alsa-devel mailing list